From 2111595d92d5756a5787dae26503de15a3885321 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Thu, 24 Oct 2024 15:47:47 +0300 Subject: [PATCH] =?utf8?q?[ERP-148]=20=D0=B8=D0=BD=D1=82=D0=B5=D0=B3=D1=80?= =?utf8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D1=81=20=D1=8F=D0=BD=D0=B4=D0=B5?= =?utf8?q?=D0=BA=D1=81=D0=BC=D0=B0=D1=80=D0=BA=D0=B5=D1=82=D0=BF=D0=BB?= =?utf8?q?=D0=B5=D0=B9=D1=81=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- FETCH_HEAD | 0 .../controllers/YandexMarketController.php | 183 + erp24/composer.json | 11 +- erp24/lib/yandex_market_api/Api/BidsApi.php | 2372 + .../Api/BusinessOfferMappingsApi.php | 3610 + .../yandex_market_api/Api/BusinessesApi.php | 673 + .../yandex_market_api/Api/CampaignsApi.php | 3383 + .../yandex_market_api/Api/CategoriesApi.php | 1192 + erp24/lib/yandex_market_api/Api/ChatsApi.php | 3037 + .../lib/yandex_market_api/Api/ContentApi.php | 1836 + erp24/lib/yandex_market_api/Api/DbsApi.php | 70501 ++++++++++++++++ .../Api/DeliveryServicesApi.php | 650 + .../lib/yandex_market_api/Api/ExpressApi.php | 59563 +++++++++++++ erp24/lib/yandex_market_api/Api/FbsApi.php | 66259 +++++++++++++++ erp24/lib/yandex_market_api/Api/FbyApi.php | 52401 ++++++++++++ .../yandex_market_api/Api/FeedbacksApi.php | 723 + erp24/lib/yandex_market_api/Api/FeedsApi.php | 3024 + .../Api/GoodsFeedbackApi.php | 2954 + .../yandex_market_api/Api/GoodsStatsApi.php | 692 + .../yandex_market_api/Api/HiddenOffersApi.php | 1870 + erp24/lib/yandex_market_api/Api/ModelsApi.php | 3071 + .../Api/OfferMappingsApi.php | 1962 + erp24/lib/yandex_market_api/Api/OffersApi.php | 3692 + .../Api/OrderBusinessInformationApi.php | 1246 + .../Api/OrderDeliveryApi.php | 2981 + .../yandex_market_api/Api/OrderLabelsApi.php | 1869 + erp24/lib/yandex_market_api/Api/OrdersApi.php | 5837 ++ .../yandex_market_api/Api/OrdersStatsApi.php | 716 + .../Api/OutletLicensesApi.php | 1818 + .../lib/yandex_market_api/Api/OutletsApi.php | 2972 + .../Api/PriceQuarantineApi.php | 2478 + erp24/lib/yandex_market_api/Api/PricesApi.php | 3030 + erp24/lib/yandex_market_api/Api/PromosApi.php | 2372 + .../lib/yandex_market_api/Api/RatingsApi.php | 1225 + .../lib/yandex_market_api/Api/RegionsApi.php | 1689 + .../lib/yandex_market_api/Api/ReportsApi.php | 8290 ++ .../lib/yandex_market_api/Api/ReturnsApi.php | 3735 + .../yandex_market_api/Api/ShipmentsApi.php | 6914 ++ erp24/lib/yandex_market_api/Api/StocksApi.php | 1233 + .../lib/yandex_market_api/Api/TariffsApi.php | 669 + .../yandex_market_api/Api/WarehousesApi.php | 1183 + erp24/lib/yandex_market_api/ApiException.php | 119 + erp24/lib/yandex_market_api/Configuration.php | 531 + .../lib/yandex_market_api/HeaderSelector.php | 273 + .../Model/AcceptOrderCancellationRequest.php | 446 + .../Model/AddHiddenOffersRequest.php | 428 + .../Model/AddOffersToArchiveDTO.php | 417 + .../Model/AddOffersToArchiveErrorDTO.php | 472 + .../Model/AddOffersToArchiveErrorType.php | 63 + .../Model/AddOffersToArchiveRequest.php | 428 + .../Model/AddOffersToArchiveResponse.php | 444 + ...ffectedOrderQualityRatingComponentType.php | 69 + erp24/lib/yandex_market_api/Model/AgeDTO.php | 459 + .../yandex_market_api/Model/AgeUnitType.php | 63 + .../Model/ApiClientDataErrorResponse.php | 451 + .../yandex_market_api/Model/ApiErrorDTO.php | 447 + .../Model/ApiErrorResponse.php | 451 + .../Model/ApiForbiddenErrorResponse.php | 451 + .../Model/ApiLimitErrorResponse.php | 451 + .../Model/ApiLockedErrorResponse.php | 451 + .../Model/ApiNotFoundErrorResponse.php | 451 + .../yandex_market_api/Model/ApiResponse.php | 410 + .../Model/ApiResponseStatusType.php | 63 + .../Model/ApiServerErrorResponse.php | 451 + .../Model/ApiUnauthorizedErrorResponse.php | 451 + .../Model/BaseCampaignOfferDTO.php | 503 + .../yandex_market_api/Model/BaseOfferDTO.php | 1375 + .../yandex_market_api/Model/BasePriceDTO.php | 459 + .../Model/BaseShipmentDTO.php | 877 + .../Model/BidRecommendationItemDTO.php | 482 + .../Model/BriefOrderItemDTO.php | 643 + .../Model/BriefOrderItemInstanceDTO.php | 512 + .../yandex_market_api/Model/BusinessDTO.php | 444 + .../Model/BusinessSettingsDTO.php | 444 + .../Model/CalculateTariffsOfferDTO.php | 695 + .../Model/CalculateTariffsOfferInfoDTO.php | 450 + .../Model/CalculateTariffsParametersDTO.php | 487 + .../Model/CalculateTariffsRequest.php | 464 + .../Model/CalculateTariffsResponse.php | 443 + .../Model/CalculateTariffsResponseDTO.php | 413 + .../Model/CalculatedTariffDTO.php | 484 + .../Model/CalculatedTariffType.php | 81 + .../yandex_market_api/Model/CampaignDTO.php | 546 + .../Model/CampaignQualityRatingDTO.php | 450 + .../Model/CampaignSettingsDTO.php | 580 + .../Model/CampaignSettingsDeliveryDTO.php | 410 + .../Model/CampaignSettingsLocalRegionDTO.php | 546 + .../Model/CampaignSettingsScheduleDTO.php | 592 + .../CampaignSettingsScheduleSourceType.php | 63 + .../Model/CampaignSettingsTimePeriodDTO.php | 444 + .../Model/CampaignsQualityRatingDTO.php | 413 + .../Model/CategoryContentParametersDTO.php | 463 + .../yandex_market_api/Model/CategoryDTO.php | 491 + .../Model/CategoryErrorDTO.php | 444 + .../Model/CategoryErrorType.php | 63 + .../Model/CategoryParameterDTO.php | 903 + .../Model/CategoryParameterUnitDTO.php | 450 + .../Model/ChangeOutletRequest.php | 780 + .../yandex_market_api/Model/ChannelType.php | 382 + .../Model/ChatMessageDTO.php | 562 + .../Model/ChatMessagePayloadDTO.php | 496 + .../Model/ChatMessageSenderType.php | 69 + .../Model/ChatMessagesResultDTO.php | 484 + .../Model/ChatStatusType.php | 75 + .../lib/yandex_market_api/Model/ChatType.php | 63 + .../Model/ConfirmPricesRequest.php | 428 + .../Model/ConfirmShipmentRequest.php | 410 + .../Model/CreateChatRequest.php | 413 + .../Model/CreateChatResponse.php | 444 + .../Model/CreateChatResultDTO.php | 422 + .../Model/CreateOutletResponse.php | 444 + .../yandex_market_api/Model/CurrencyType.php | 426 + .../yandex_market_api/Model/DayOfWeekType.php | 78 + .../Model/DeleteCampaignOffersDTO.php | 417 + .../Model/DeleteCampaignOffersRequest.php | 428 + .../Model/DeleteCampaignOffersResponse.php | 444 + .../DeleteGoodsFeedbackCommentRequest.php | 413 + .../Model/DeleteHiddenOffersRequest.php | 428 + .../Model/DeleteOffersDTO.php | 417 + .../Model/DeleteOffersFromArchiveDTO.php | 417 + .../Model/DeleteOffersFromArchiveRequest.php | 428 + .../Model/DeleteOffersFromArchiveResponse.php | 444 + .../Model/DeleteOffersRequest.php | 428 + .../Model/DeleteOffersResponse.php | 444 + .../Model/DeletePromoOffersRequest.php | 503 + .../Model/DeletePromoOffersResponse.php | 444 + .../Model/DeletePromoOffersResultDTO.php | 417 + .../Model/DeliveryServiceDTO.php | 444 + .../Model/DeliveryServiceInfoDTO.php | 450 + .../Model/DeliveryServicesDTO.php | 413 + .../yandex_market_api/Model/DocumentDTO.php | 478 + .../Model/EacVerificationResultDTO.php | 444 + .../Model/EacVerificationStatusType.php | 66 + .../Model/EmptyApiResponse.php | 410 + .../Model/EnrichedMappingsOfferDTO.php | 1745 + .../Model/EnrichedModelDTO.php | 587 + .../Model/EnrichedModelsDTO.php | 413 + .../Model/EnrichedOrderBoxLayoutDTO.php | 456 + .../Model/ExtensionShipmentDTO.php | 449 + .../Model/FeedContentDTO.php | 512 + .../Model/FeedContentErrorDTO.php | 410 + .../Model/FeedContentErrorType.php | 66 + erp24/lib/yandex_market_api/Model/FeedDTO.php | 716 + .../Model/FeedDownloadDTO.php | 444 + .../Model/FeedDownloadErrorDTO.php | 478 + .../Model/FeedDownloadErrorType.php | 63 + .../Model/FeedIndexLogsErrorDTO.php | 478 + .../Model/FeedIndexLogsErrorType.php | 75 + .../Model/FeedIndexLogsFeedDTO.php | 410 + .../Model/FeedIndexLogsIndexType.php | 66 + .../Model/FeedIndexLogsOffersDTO.php | 444 + .../Model/FeedIndexLogsRecordDTO.php | 648 + .../Model/FeedIndexLogsResultDTO.php | 481 + .../Model/FeedIndexLogsStatusType.php | 66 + .../Model/FeedParameterDTO.php | 488 + .../Model/FeedPlacementDTO.php | 444 + .../Model/FeedPublicationDTO.php | 478 + .../Model/FeedPublicationFullDTO.php | 444 + .../FeedPublicationPriceAndStockUpdateDTO.php | 444 + .../Model/FeedStatusType.php | 66 + .../Model/FeedbackAuthorDTO.php | 444 + .../Model/FeedbackCommentAuthorDTO.php | 444 + .../Model/FeedbackCommentAuthorType.php | 63 + .../Model/FeedbackCommentDTO.php | 621 + .../yandex_market_api/Model/FeedbackDTO.php | 855 + .../Model/FeedbackDeliveryType.php | 66 + .../Model/FeedbackFactorDTO.php | 512 + .../Model/FeedbackGradesDTO.php | 515 + .../Model/FeedbackListDTO.php | 447 + .../Model/FeedbackOrderDTO.php | 444 + .../Model/FeedbackReactionStatusType.php | 63 + .../Model/FeedbackShopDTO.php | 410 + .../Model/FeedbackStateType.php | 66 + .../Model/FieldStateType.php | 63 + .../Model/FlippingPagerDTO.php | 580 + .../Model/ForwardScrollingPagerDTO.php | 410 + .../Model/FulfillmentWarehouseDTO.php | 484 + .../Model/FulfillmentWarehousesDTO.php | 413 + .../yandex_market_api/Model/FullOutletDTO.php | 988 + .../Model/FullOutletLicenseDTO.php | 672 + .../GenerateBoostConsolidatedRequest.php | 487 + ...nerateCompetitorsPositionReportRequest.php | 524 + .../Model/GenerateGoodsFeedbackRequest.php | 413 + .../GenerateGoodsMovementReportRequest.php | 552 + .../GenerateGoodsRealizationReportRequest.php | 503 + .../Model/GenerateGoodsTurnoverRequest.php | 447 + .../Model/GenerateMassOrderLabelsRequest.php | 499 + .../Model/GeneratePricesReportRequest.php | 553 + .../Model/GenerateReportDTO.php | 450 + .../Model/GenerateReportResponse.php | 444 + .../Model/GenerateShelfsStatisticsRequest.php | 524 + ...erateShipmentListDocumentReportRequest.php | 488 + .../Model/GenerateShowsSalesReportRequest.php | 555 + ...enerateStocksOnWarehousesReportRequest.php | 563 + ...UnitedMarketplaceServicesReportRequest.php | 840 + .../GenerateUnitedNettingReportRequest.php | 740 + .../Model/GenerateUnitedOrdersRequest.php | 562 + .../Model/GetAllOffersResponse.php | 413 + .../Model/GetBidsInfoRequest.php | 432 + .../Model/GetBidsInfoResponse.php | 444 + .../Model/GetBidsInfoResponseDTO.php | 447 + .../Model/GetBidsRecommendationsRequest.php | 428 + .../Model/GetBidsRecommendationsResponse.php | 444 + .../GetBidsRecommendationsResponseDTO.php | 413 + .../Model/GetBusinessBuyerInfoResponse.php | 443 + .../GetBusinessDocumentsInfoResponse.php | 443 + .../Model/GetBusinessSettingsInfoDTO.php | 444 + .../Model/GetBusinessSettingsResponse.php | 444 + .../Model/GetCampaignLoginsResponse.php | 413 + .../Model/GetCampaignOfferDTO.php | 687 + .../Model/GetCampaignOffersRequest.php | 589 + .../Model/GetCampaignOffersResponse.php | 444 + .../Model/GetCampaignOffersResultDTO.php | 447 + .../Model/GetCampaignRegionResponse.php | 410 + .../Model/GetCampaignResponse.php | 410 + .../Model/GetCampaignSettingsResponse.php | 410 + .../Model/GetCampaignsResponse.php | 447 + .../Model/GetCategoriesMaxSaleQuantumDTO.php | 454 + .../GetCategoriesMaxSaleQuantumRequest.php | 428 + .../GetCategoriesMaxSaleQuantumResponse.php | 487 + .../Model/GetCategoriesRequest.php | 410 + .../Model/GetCategoriesResponse.php | 443 + .../GetCategoryContentParametersResponse.php | 444 + .../Model/GetChatHistoryRequest.php | 419 + .../Model/GetChatHistoryResponse.php | 443 + .../Model/GetChatInfoDTO.php | 607 + .../Model/GetChatsInfoDTO.php | 447 + .../Model/GetChatsRequest.php | 526 + .../Model/GetChatsResponse.php | 443 + .../Model/GetDeliveryServicesResponse.php | 410 + .../Model/GetFeedIndexLogsResponse.php | 443 + .../Model/GetFeedResponse.php | 410 + .../Model/GetFeedbackListResponse.php | 443 + .../Model/GetFeedsResponse.php | 413 + .../GetFulfillmentWarehousesResponse.php | 443 + .../Model/GetGoodsFeedbackCommentsRequest.php | 413 + .../GetGoodsFeedbackCommentsResponse.php | 443 + .../Model/GetGoodsFeedbackRequest.php | 610 + .../Model/GetGoodsFeedbackResponse.php | 443 + .../Model/GetGoodsStatsRequest.php | 428 + .../Model/GetGoodsStatsResponse.php | 444 + .../Model/GetHiddenOffersResponse.php | 444 + .../Model/GetHiddenOffersResultDTO.php | 447 + .../yandex_market_api/Model/GetMappingDTO.php | 589 + .../Model/GetModelsOffersResponse.php | 481 + .../Model/GetModelsRequest.php | 422 + .../Model/GetModelsResponse.php | 481 + .../GetOfferCardsContentStatusRequest.php | 516 + .../GetOfferCardsContentStatusResponse.php | 444 + .../yandex_market_api/Model/GetOfferDTO.php | 1661 + .../Model/GetOfferMappingDTO.php | 444 + .../Model/GetOfferMappingEntriesResponse.php | 444 + .../Model/GetOfferMappingsRequest.php | 665 + .../Model/GetOfferMappingsResponse.php | 443 + .../Model/GetOfferMappingsResultDTO.php | 447 + .../Model/GetOfferRecommendationsRequest.php | 518 + .../Model/GetOfferRecommendationsResponse.php | 443 + .../Model/GetOffersResponse.php | 447 + .../Model/GetOrderBuyerInfoResponse.php | 443 + .../Model/GetOrderLabelsDataResponse.php | 444 + .../Model/GetOrderResponse.php | 409 + .../Model/GetOrdersResponse.php | 489 + .../Model/GetOrdersStatsRequest.php | 628 + .../Model/GetOrdersStatsResponse.php | 444 + .../Model/GetOutletLicensesResponse.php | 443 + .../Model/GetOutletResponse.php | 410 + .../Model/GetOutletsResponse.php | 481 + .../yandex_market_api/Model/GetPriceDTO.php | 496 + .../Model/GetPriceWithDiscountDTO.php | 539 + .../Model/GetPriceWithVatDTO.php | 549 + .../Model/GetPricesByOfferIdsRequest.php | 432 + .../Model/GetPricesByOfferIdsResponse.php | 444 + .../Model/GetPricesResponse.php | 444 + .../Model/GetPromoAssortmentInfoDTO.php | 481 + .../Model/GetPromoBestsellerInfoDTO.php | 447 + .../Model/GetPromoConstraintsDTO.php | 417 + .../yandex_market_api/Model/GetPromoDTO.php | 710 + .../Model/GetPromoMechanicsInfoDTO.php | 447 + .../Model/GetPromoOfferDTO.php | 543 + .../Model/GetPromoOffersRequest.php | 447 + .../Model/GetPromoOffersResponse.php | 443 + .../Model/GetPromoOffersResultDTO.php | 447 + .../Model/GetPromoPromocodeInfoDTO.php | 450 + .../Model/GetPromosRequest.php | 444 + .../Model/GetPromosResponse.php | 443 + .../Model/GetPromosResultDTO.php | 413 + .../Model/GetQualityRatingDetailsResponse.php | 443 + .../Model/GetQualityRatingRequest.php | 496 + .../Model/GetQualityRatingResponse.php | 444 + .../Model/GetQuarantineOffersRequest.php | 632 + .../Model/GetQuarantineOffersResponse.php | 444 + .../Model/GetQuarantineOffersResultDTO.php | 447 + .../Model/GetRegionWithChildrenResponse.php | 443 + .../Model/GetRegionsResponse.php | 446 + .../Model/GetReportInfoResponse.php | 444 + .../Model/GetReturnResponse.php | 443 + .../Model/GetReturnsResponse.php | 443 + .../Model/GetShipmentOrdersInfoResponse.php | 443 + .../Model/GetShipmentResponse.php | 443 + ...GetSuggestedOfferMappingEntriesRequest.php | 428 + ...etSuggestedOfferMappingEntriesResponse.php | 444 + .../GetSuggestedOfferMappingsRequest.php | 431 + .../GetSuggestedOfferMappingsResponse.php | 443 + .../GetSuggestedOfferMappingsResultDTO.php | 413 + .../Model/GetWarehouseStocksDTO.php | 447 + .../Model/GetWarehouseStocksRequest.php | 493 + .../Model/GetWarehouseStocksResponse.php | 443 + .../Model/GetWarehousesResponse.php | 443 + .../Model/GoodsFeedbackCommentAuthorDTO.php | 444 + .../Model/GoodsFeedbackCommentAuthorType.php | 63 + .../Model/GoodsFeedbackCommentDTO.php | 607 + .../Model/GoodsFeedbackCommentListDTO.php | 447 + .../Model/GoodsFeedbackCommentStatusType.php | 69 + .../Model/GoodsFeedbackDTO.php | 663 + .../Model/GoodsFeedbackDescriptionDTO.php | 478 + .../Model/GoodsFeedbackIdentifiersDTO.php | 450 + .../Model/GoodsFeedbackListDTO.php | 447 + .../Model/GoodsFeedbackMediaDTO.php | 458 + .../Model/GoodsFeedbackStatisticsDTO.php | 534 + .../yandex_market_api/Model/GoodsStatsDTO.php | 413 + .../Model/GoodsStatsGoodsDTO.php | 768 + .../Model/GoodsStatsWarehouseDTO.php | 481 + .../Model/GoodsStatsWeightDimensionsDTO.php | 512 + erp24/lib/yandex_market_api/Model/GpsDTO.php | 450 + .../Model/HiddenOfferDTO.php | 435 + .../Model/LabelsSortingType.php | 63 + .../yandex_market_api/Model/LanguageType.php | 63 + .../Model/LicenseCheckStatusType.php | 75 + .../yandex_market_api/Model/LicenseType.php | 63 + .../Model/LogisticPickupPointDTO.php | 580 + .../Model/LogisticPointType.php | 78 + .../Model/MappingsOfferDTO.php | 1532 + .../Model/MappingsOfferInfoDTO.php | 1498 + .../Model/MaxSaleQuantumDTO.php | 481 + .../yandex_market_api/Model/MechanicsType.php | 66 + .../lib/yandex_market_api/Model/ModelDTO.php | 478 + .../Model/ModelInterface.php | 111 + .../yandex_market_api/Model/ModelOfferDTO.php | 718 + .../yandex_market_api/Model/ModelPriceDTO.php | 478 + .../lib/yandex_market_api/Model/ModelsDTO.php | 413 + .../Model/OfferAvailabilityStatusType.php | 66 + .../Model/OfferCampaignStatusDTO.php | 450 + .../Model/OfferCampaignStatusType.php | 84 + .../yandex_market_api/Model/OfferCardDTO.php | 701 + .../Model/OfferCardRecommendationDTO.php | 463 + .../Model/OfferCardRecommendationType.php | 108 + .../Model/OfferCardStatusType.php | 84 + .../Model/OfferCardsContentStatusDTO.php | 447 + .../Model/OfferConditionDTO.php | 478 + .../Model/OfferConditionQualityType.php | 69 + .../Model/OfferConditionType.php | 75 + .../Model/OfferContentDTO.php | 533 + .../Model/OfferContentErrorDTO.php | 484 + .../Model/OfferContentErrorType.php | 90 + .../lib/yandex_market_api/Model/OfferDTO.php | 923 + .../yandex_market_api/Model/OfferErrorDTO.php | 444 + .../Model/OfferForRecommendationDTO.php | 568 + .../Model/OfferManualDTO.php | 447 + .../Model/OfferMappingDTO.php | 487 + .../Model/OfferMappingEntriesDTO.php | 447 + .../Model/OfferMappingEntryDTO.php | 512 + .../Model/OfferMappingErrorDTO.php | 484 + .../Model/OfferMappingErrorType.php | 96 + .../Model/OfferMappingInfoDTO.php | 478 + .../Model/OfferMappingKindType.php | 63 + .../Model/OfferMappingSuggestionsListDTO.php | 413 + .../yandex_market_api/Model/OfferParamDTO.php | 450 + .../OfferPriceByOfferIdsListResponseDTO.php | 447 + .../Model/OfferPriceByOfferIdsResponseDTO.php | 500 + .../yandex_market_api/Model/OfferPriceDTO.php | 466 + .../Model/OfferPriceListResponseDTO.php | 481 + .../Model/OfferPriceResponseDTO.php | 521 + .../Model/OfferProcessingNoteDTO.php | 444 + .../Model/OfferProcessingNoteType.php | 105 + .../Model/OfferProcessingStateDTO.php | 451 + .../Model/OfferProcessingStatusType.php | 93 + .../Model/OfferRecommendationDTO.php | 444 + .../Model/OfferRecommendationInfoDTO.php | 500 + .../Model/OfferRecommendationsResultDTO.php | 447 + .../Model/OfferSellingProgramDTO.php | 450 + .../Model/OfferSellingProgramStatusType.php | 63 + .../lib/yandex_market_api/Model/OfferType.php | 78 + .../Model/OfferWeightDimensionsDTO.php | 524 + .../lib/yandex_market_api/Model/OffersDTO.php | 413 + .../Model/OptionValuesLimitedDTO.php | 450 + .../Model/OrderBoxLayoutDTO.php | 422 + .../Model/OrderBoxLayoutItemDTO.php | 531 + .../Model/OrderBoxLayoutPartialCountDTO.php | 468 + .../Model/OrderBoxesLayoutDTO.php | 413 + .../Model/OrderBusinessBuyerDTO.php | 512 + .../Model/OrderBusinessDocumentsDTO.php | 546 + .../Model/OrderBuyerBasicInfoDTO.php | 546 + .../yandex_market_api/Model/OrderBuyerDTO.php | 546 + .../Model/OrderBuyerInfoDTO.php | 580 + .../Model/OrderBuyerType.php | 63 + .../Model/OrderCancellationReasonType.php | 63 + .../Model/OrderCourierDTO.php | 546 + .../lib/yandex_market_api/Model/OrderDTO.php | 1174 + .../Model/OrderDeliveryAddressDTO.php | 886 + .../Model/OrderDeliveryDTO.php | 1106 + .../Model/OrderDeliveryDateDTO.php | 413 + .../Model/OrderDeliveryDateReasonType.php | 63 + .../Model/OrderDeliveryDatesDTO.php | 546 + .../Model/OrderDeliveryDispatchType.php | 69 + .../Model/OrderDeliveryEacType.php | 66 + .../Model/OrderDeliveryPartnerType.php | 66 + .../Model/OrderDeliveryType.php | 72 + .../Model/OrderDigitalItemDTO.php | 524 + .../Model/OrderDocumentStatusType.php | 63 + .../yandex_market_api/Model/OrderItemDTO.php | 1080 + .../Model/OrderItemDetailDTO.php | 478 + .../Model/OrderItemInstanceDTO.php | 546 + .../OrderItemInstanceModificationDTO.php | 450 + .../Model/OrderItemInstanceType.php | 72 + .../Model/OrderItemModificationDTO.php | 500 + .../Model/OrderItemPromoDTO.php | 549 + .../Model/OrderItemStatusType.php | 63 + .../Model/OrderItemSubsidyDTO.php | 444 + .../Model/OrderItemSubsidyType.php | 63 + .../Model/OrderItemTagType.php | 66 + ...rderItemsModificationRequestReasonType.php | 63 + .../Model/OrderItemsModificationResultDTO.php | 413 + .../yandex_market_api/Model/OrderLabelDTO.php | 524 + .../yandex_market_api/Model/OrderLiftType.php | 75 + .../Model/OrderParcelBoxDTO.php | 444 + .../Model/OrderPaymentMethodType.php | 99 + .../Model/OrderPaymentType.php | 66 + .../Model/OrderPromoType.php | 156 + .../Model/OrderShipmentDTO.php | 560 + .../yandex_market_api/Model/OrderStateDTO.php | 484 + .../Model/OrderStatsStatusType.php | 102 + .../Model/OrderStatusChangeDTO.php | 481 + .../Model/OrderStatusChangeDeliveryDTO.php | 410 + .../OrderStatusChangeDeliveryDatesDTO.php | 410 + .../Model/OrderStatusType.php | 93 + .../Model/OrderSubsidyDTO.php | 444 + .../Model/OrderSubsidyType.php | 66 + .../Model/OrderSubstatusType.php | 399 + .../Model/OrderTaxSystemType.php | 81 + .../yandex_market_api/Model/OrderTrackDTO.php | 444 + .../Model/OrderUpdateStatusType.php | 63 + .../yandex_market_api/Model/OrderVatType.php | 84 + .../Model/OrdersShipmentInfoDTO.php | 454 + .../Model/OrdersStatsCommissionDTO.php | 444 + .../Model/OrdersStatsCommissionType.php | 99 + .../Model/OrdersStatsDTO.php | 447 + .../Model/OrdersStatsDeliveryRegionDTO.php | 444 + .../Model/OrdersStatsDetailsDTO.php | 512 + .../Model/OrdersStatsItemDTO.php | 852 + .../Model/OrdersStatsItemStatusType.php | 63 + .../Model/OrdersStatsOrderDTO.php | 800 + .../Model/OrdersStatsOrderPaymentType.php | 69 + .../Model/OrdersStatsPaymentDTO.php | 580 + .../Model/OrdersStatsPaymentOrderDTO.php | 444 + .../Model/OrdersStatsPaymentSourceType.php | 69 + .../Model/OrdersStatsPaymentType.php | 66 + .../Model/OrdersStatsPriceDTO.php | 478 + .../Model/OrdersStatsPriceType.php | 66 + .../Model/OrdersStatsStockType.php | 78 + .../Model/OrdersStatsWarehouseDTO.php | 444 + .../Model/OutletAddressDTO.php | 733 + .../lib/yandex_market_api/Model/OutletDTO.php | 781 + .../Model/OutletDeliveryRuleDTO.php | 628 + .../Model/OutletLicenseDTO.php | 604 + .../Model/OutletLicensesResponseDTO.php | 413 + .../Model/OutletResponseDTO.php | 410 + .../Model/OutletStatusType.php | 72 + .../yandex_market_api/Model/OutletType.php | 69 + .../Model/OutletVisibilityType.php | 66 + .../Model/OutletWorkingScheduleDTO.php | 456 + .../Model/OutletWorkingScheduleItemDTO.php | 542 + .../Model/PageFormatType.php | 63 + .../Model/PagedReturnsDTO.php | 447 + .../Model/PalletsCountDTO.php | 462 + .../yandex_market_api/Model/ParameterType.php | 69 + .../Model/ParameterValueConstraintsDTO.php | 478 + .../Model/ParameterValueDTO.php | 524 + .../Model/ParameterValueOptionDTO.php | 484 + .../yandex_market_api/Model/ParcelBoxDTO.php | 453 + .../Model/ParcelBoxLabelDTO.php | 851 + .../lib/yandex_market_api/Model/ParcelDTO.php | 422 + .../Model/PartnerShipmentWarehouseDTO.php | 490 + .../Model/PaymentFrequencyType.php | 69 + .../Model/PickupAddressDTO.php | 546 + .../yandex_market_api/Model/PlacementType.php | 66 + .../PriceCompetitivenessThresholdsDTO.php | 444 + .../Model/PriceCompetitivenessType.php | 66 + .../lib/yandex_market_api/Model/PriceDTO.php | 512 + .../Model/PriceQuarantineVerdictDTO.php | 447 + .../PriceQuarantineVerdictParamNameType.php | 69 + .../PriceQuarantineVerdictParameterDTO.php | 450 + .../Model/PriceQuarantineVerdictType.php | 66 + .../Model/PriceRecommendationItemDTO.php | 459 + .../Model/PriceSuggestDTO.php | 444 + .../Model/PriceSuggestOfferDTO.php | 516 + .../Model/PriceSuggestType.php | 66 + .../PromoOfferAutoParticipatingDetailsDTO.php | 417 + .../Model/PromoOfferDiscountParamsDTO.php | 481 + .../Model/PromoOfferParamsDTO.php | 444 + ...romoOfferParticipationStatusFilterType.php | 63 + .../PromoOfferParticipationStatusType.php | 69 + .../Model/PromoOfferPromocodeParamsDTO.php | 413 + .../Model/PromoOfferUpdateWarningCodeType.php | 72 + .../Model/PromoOfferUpdateWarningDTO.php | 454 + .../Model/PromoParticipationType.php | 63 + .../Model/PromoPeriodDTO.php | 450 + .../Model/ProvideOrderDigitalCodesRequest.php | 413 + .../ProvideOrderItemIdentifiersRequest.php | 412 + .../ProvideOrderItemIdentifiersResponse.php | 443 + .../Model/PutSkuBidsRequest.php | 428 + .../Model/QualityRatingAffectedOrderDTO.php | 496 + .../Model/QualityRatingComponentDTO.php | 466 + .../Model/QualityRatingComponentType.php | 81 + .../Model/QualityRatingDTO.php | 503 + .../Model/QualityRatingDetailsDTO.php | 413 + .../yandex_market_api/Model/QuantumDTO.php | 469 + .../Model/QuarantineOfferDTO.php | 541 + .../yandex_market_api/Model/RecipientType.php | 66 + .../Model/RefundStatusType.php | 90 + .../lib/yandex_market_api/Model/RegionDTO.php | 559 + .../yandex_market_api/Model/RegionType.php | 90 + .../Model/RegionalModelInfoDTO.php | 444 + .../Model/RejectedPromoOfferDeleteDTO.php | 472 + .../RejectedPromoOfferDeleteReasonType.php | 60 + .../Model/RejectedPromoOfferUpdateDTO.php | 472 + .../RejectedPromoOfferUpdateReasonType.php | 87 + .../Model/ReportFormatType.php | 63 + .../yandex_market_api/Model/ReportInfoDTO.php | 586 + .../Model/ReportStatusType.php | 69 + .../Model/ReportSubStatusType.php | 66 + .../lib/yandex_market_api/Model/ReturnDTO.php | 796 + .../Model/ReturnDecisionDTO.php | 689 + .../Model/ReturnDecisionReasonType.php | 78 + .../Model/ReturnDecisionSubreasonType.php | 90 + .../Model/ReturnDecisionType.php | 81 + .../Model/ReturnInstanceDTO.php | 512 + .../Model/ReturnInstanceStatusType.php | 93 + .../Model/ReturnInstanceStockType.php | 114 + .../yandex_market_api/Model/ReturnItemDTO.php | 638 + .../Model/ReturnRequestDecisionType.php | 78 + .../Model/ReturnShipmentStatusType.php | 99 + .../yandex_market_api/Model/ReturnType.php | 63 + .../Model/ScrollingPagerDTO.php | 444 + .../Model/SearchModelsResponse.php | 514 + .../Model/SearchShipmentsRequest.php | 584 + .../Model/SearchShipmentsResponse.php | 444 + .../Model/SearchShipmentsResponseDTO.php | 447 + .../Model/SellingProgramType.php | 69 + .../Model/SendMessageToChatRequest.php | 428 + .../Model/SetFeedParamsRequest.php | 413 + .../Model/SetOrderBoxLayoutRequest.php | 455 + .../Model/SetOrderBoxLayoutResponse.php | 443 + .../Model/SetOrderDeliveryDateRequest.php | 449 + .../SetOrderDeliveryTrackCodeRequest.php | 449 + .../Model/SetOrderShipmentBoxesRequest.php | 421 + .../Model/SetOrderShipmentBoxesResponse.php | 443 + .../Model/SetReturnDecisionRequest.php | 484 + .../Model/SetShipmentPalletsCountRequest.php | 422 + .../Model/ShelfsStatisticsAttributionType.php | 63 + .../Model/ShipmentActionType.php | 72 + .../Model/ShipmentBoxesDTO.php | 413 + .../yandex_market_api/Model/ShipmentDTO.php | 950 + .../Model/ShipmentInfoDTO.php | 979 + .../ShipmentPalletLabelPageFormatType.php | 63 + .../Model/ShipmentStatusChangeDTO.php | 478 + .../Model/ShipmentStatusType.php | 81 + .../yandex_market_api/Model/ShipmentType.php | 63 + .../Model/ShowsSalesGroupingType.php | 63 + .../SkipGoodsFeedbackReactionRequest.php | 428 + .../yandex_market_api/Model/SkuBidItemDTO.php | 488 + .../Model/SkuBidRecommendationItemDTO.php | 570 + .../yandex_market_api/Model/SortOrderType.php | 63 + .../Model/SuggestOfferPriceDTO.php | 475 + .../Model/SuggestPricesRequest.php | 421 + .../Model/SuggestPricesResponse.php | 444 + .../Model/SuggestPricesResultDTO.php | 413 + .../Model/SuggestedOfferDTO.php | 693 + .../Model/SuggestedOfferMappingDTO.php | 444 + .../lib/yandex_market_api/Model/TariffDTO.php | 523 + .../Model/TariffParameterDTO.php | 450 + .../yandex_market_api/Model/TariffType.php | 135 + .../yandex_market_api/Model/TimePeriodDTO.php | 484 + .../yandex_market_api/Model/TimeUnitType.php | 72 + .../lib/yandex_market_api/Model/TrackDTO.php | 410 + .../TransferOrdersFromShipmentRequest.php | 428 + .../yandex_market_api/Model/TurnoverDTO.php | 447 + .../yandex_market_api/Model/TurnoverType.php | 75 + erp24/lib/yandex_market_api/Model/UnitDTO.php | 487 + .../Model/UpdateBusinessOfferPriceDTO.php | 472 + .../Model/UpdateBusinessPricesRequest.php | 428 + .../Model/UpdateCampaignOfferDTO.php | 537 + .../Model/UpdateCampaignOffersRequest.php | 428 + .../Model/UpdateGoodsFeedbackCommentDTO.php | 496 + .../UpdateGoodsFeedbackCommentRequest.php | 450 + .../UpdateGoodsFeedbackCommentResponse.php | 443 + .../Model/UpdateMappingDTO.php | 419 + .../Model/UpdateMappingsOfferDTO.php | 1498 + .../Model/UpdateOfferContentRequest.php | 428 + .../Model/UpdateOfferContentResponse.php | 451 + .../Model/UpdateOfferContentResultDTO.php | 517 + .../Model/UpdateOfferDTO.php | 1560 + .../Model/UpdateOfferMappingDTO.php | 447 + .../Model/UpdateOfferMappingEntryDTO.php | 512 + .../Model/UpdateOfferMappingEntryRequest.php | 428 + .../Model/UpdateOfferMappingResultDTO.php | 517 + .../Model/UpdateOfferMappingsRequest.php | 461 + .../Model/UpdateOfferMappingsResponse.php | 451 + .../Model/UpdateOrderItemRequest.php | 456 + .../Model/UpdateOrderStatusDTO.php | 546 + .../Model/UpdateOrderStatusRequest.php | 412 + .../Model/UpdateOrderStatusResponse.php | 410 + .../Model/UpdateOrderStatusesDTO.php | 413 + .../Model/UpdateOrderStatusesRequest.php | 428 + .../Model/UpdateOrderStatusesResponse.php | 443 + .../Model/UpdateOrderStorageLimitRequest.php | 413 + .../Model/UpdateOutletLicenseRequest.php | 422 + .../Model/UpdatePriceWithDiscountDTO.php | 502 + .../Model/UpdatePricesRequest.php | 428 + .../Model/UpdatePromoOfferDTO.php | 469 + .../UpdatePromoOfferDiscountParamsDTO.php | 462 + .../Model/UpdatePromoOfferParamsDTO.php | 410 + .../Model/UpdatePromoOffersRequest.php | 465 + .../Model/UpdatePromoOffersResponse.php | 444 + .../Model/UpdatePromoOffersResultDTO.php | 458 + .../Model/UpdateStockDTO.php | 487 + .../Model/UpdateStockItemDTO.php | 463 + .../Model/UpdateStocksRequest.php | 428 + .../yandex_market_api/Model/UpdateTimeDTO.php | 413 + .../Model/ValueRestrictionDTO.php | 459 + .../Model/VerifyOrderEacRequest.php | 409 + .../Model/VerifyOrderEacResponse.php | 443 + .../Model/WarehouseAddressDTO.php | 626 + .../yandex_market_api/Model/WarehouseDTO.php | 558 + .../Model/WarehouseGroupDTO.php | 487 + .../Model/WarehouseOfferDTO.php | 540 + .../Model/WarehouseOffersDTO.php | 450 + .../Model/WarehouseStockDTO.php | 450 + .../Model/WarehouseStockType.php | 78 + .../yandex_market_api/Model/WarehousesDTO.php | 450 + .../Model/WarningPromoOfferUpdateDTO.php | 472 + .../yandex_market_api/ObjectSerializer.php | 617 + sql | 0 642 files changed, 585524 insertions(+), 2 deletions(-) delete mode 100644 FETCH_HEAD create mode 100644 erp24/api2/controllers/YandexMarketController.php create mode 100644 erp24/lib/yandex_market_api/Api/BidsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/BusinessOfferMappingsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/BusinessesApi.php create mode 100644 erp24/lib/yandex_market_api/Api/CampaignsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/CategoriesApi.php create mode 100644 erp24/lib/yandex_market_api/Api/ChatsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/ContentApi.php create mode 100644 erp24/lib/yandex_market_api/Api/DbsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/DeliveryServicesApi.php create mode 100644 erp24/lib/yandex_market_api/Api/ExpressApi.php create mode 100644 erp24/lib/yandex_market_api/Api/FbsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/FbyApi.php create mode 100644 erp24/lib/yandex_market_api/Api/FeedbacksApi.php create mode 100644 erp24/lib/yandex_market_api/Api/FeedsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/GoodsFeedbackApi.php create mode 100644 erp24/lib/yandex_market_api/Api/GoodsStatsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/HiddenOffersApi.php create mode 100644 erp24/lib/yandex_market_api/Api/ModelsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OfferMappingsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OffersApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OrderBusinessInformationApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OrderDeliveryApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OrderLabelsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OrdersApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OrdersStatsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OutletLicensesApi.php create mode 100644 erp24/lib/yandex_market_api/Api/OutletsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/PriceQuarantineApi.php create mode 100644 erp24/lib/yandex_market_api/Api/PricesApi.php create mode 100644 erp24/lib/yandex_market_api/Api/PromosApi.php create mode 100644 erp24/lib/yandex_market_api/Api/RatingsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/RegionsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/ReportsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/ReturnsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/ShipmentsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/StocksApi.php create mode 100644 erp24/lib/yandex_market_api/Api/TariffsApi.php create mode 100644 erp24/lib/yandex_market_api/Api/WarehousesApi.php create mode 100644 erp24/lib/yandex_market_api/ApiException.php create mode 100644 erp24/lib/yandex_market_api/Configuration.php create mode 100644 erp24/lib/yandex_market_api/HeaderSelector.php create mode 100644 erp24/lib/yandex_market_api/Model/AcceptOrderCancellationRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/AddHiddenOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/AddOffersToArchiveDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/AddOffersToArchiveErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/AddOffersToArchiveErrorType.php create mode 100644 erp24/lib/yandex_market_api/Model/AddOffersToArchiveRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/AddOffersToArchiveResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/AffectedOrderQualityRatingComponentType.php create mode 100644 erp24/lib/yandex_market_api/Model/AgeDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/AgeUnitType.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiClientDataErrorResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiErrorResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiForbiddenErrorResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiLimitErrorResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiLockedErrorResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiNotFoundErrorResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiResponseStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiServerErrorResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/ApiUnauthorizedErrorResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/BaseCampaignOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/BaseOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/BasePriceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/BaseShipmentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/BidRecommendationItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/BriefOrderItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/BriefOrderItemInstanceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/BusinessDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/BusinessSettingsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CalculateTariffsOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CalculateTariffsOfferInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CalculateTariffsParametersDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CalculateTariffsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/CalculateTariffsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/CalculateTariffsResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CalculatedTariffDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CalculatedTariffType.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignQualityRatingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignSettingsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignSettingsDeliveryDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignSettingsLocalRegionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignSettingsScheduleDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignSettingsScheduleSourceType.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignSettingsTimePeriodDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CampaignsQualityRatingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CategoryContentParametersDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CategoryDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CategoryErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CategoryErrorType.php create mode 100644 erp24/lib/yandex_market_api/Model/CategoryParameterDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CategoryParameterUnitDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ChangeOutletRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/ChannelType.php create mode 100644 erp24/lib/yandex_market_api/Model/ChatMessageDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ChatMessagePayloadDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ChatMessageSenderType.php create mode 100644 erp24/lib/yandex_market_api/Model/ChatMessagesResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ChatStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/ChatType.php create mode 100644 erp24/lib/yandex_market_api/Model/ConfirmPricesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/ConfirmShipmentRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/CreateChatRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/CreateChatResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/CreateChatResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/CreateOutletResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/CurrencyType.php create mode 100644 erp24/lib/yandex_market_api/Model/DayOfWeekType.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteCampaignOffersDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteCampaignOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteCampaignOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteGoodsFeedbackCommentRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteHiddenOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteOffersDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/DeleteOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/DeletePromoOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/DeletePromoOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/DeletePromoOffersResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/DeliveryServiceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/DeliveryServiceInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/DeliveryServicesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/DocumentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/EacVerificationResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/EacVerificationStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/EmptyApiResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/EnrichedMappingsOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/EnrichedModelDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/EnrichedModelsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/EnrichedOrderBoxLayoutDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ExtensionShipmentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedContentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedContentErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedContentErrorType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedDownloadDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedDownloadErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedDownloadErrorType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedIndexLogsErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedIndexLogsErrorType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedIndexLogsFeedDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedIndexLogsIndexType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedIndexLogsOffersDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedIndexLogsRecordDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedIndexLogsResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedIndexLogsStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedParameterDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedPlacementDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedPublicationDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedPublicationFullDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedPublicationPriceAndStockUpdateDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackAuthorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackCommentAuthorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackCommentAuthorType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackCommentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackDeliveryType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackFactorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackGradesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackListDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackOrderDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackReactionStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackShopDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FeedbackStateType.php create mode 100644 erp24/lib/yandex_market_api/Model/FieldStateType.php create mode 100644 erp24/lib/yandex_market_api/Model/FlippingPagerDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ForwardScrollingPagerDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FulfillmentWarehouseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FulfillmentWarehousesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FullOutletDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/FullOutletLicenseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateBoostConsolidatedRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateCompetitorsPositionReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateGoodsFeedbackRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateGoodsMovementReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateGoodsRealizationReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateGoodsTurnoverRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateMassOrderLabelsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GeneratePricesReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateReportDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateReportResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateShelfsStatisticsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateShipmentListDocumentReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateShowsSalesReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateStocksOnWarehousesReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateUnitedMarketplaceServicesReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateUnitedNettingReportRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GenerateUnitedOrdersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetAllOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBidsInfoRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBidsInfoResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBidsInfoResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBidsRecommendationsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBidsRecommendationsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBidsRecommendationsResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBusinessBuyerInfoResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBusinessDocumentsInfoResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBusinessSettingsInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetBusinessSettingsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignLoginsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignOffersResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignRegionResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignSettingsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCampaignsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCategoriesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCategoriesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetCategoryContentParametersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetChatHistoryRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetChatHistoryResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetChatInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetChatsInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetChatsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetChatsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetDeliveryServicesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetFeedIndexLogsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetFeedResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetFeedbackListResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetFeedsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetFulfillmentWarehousesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetGoodsFeedbackCommentsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetGoodsFeedbackCommentsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetGoodsFeedbackRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetGoodsFeedbackResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetGoodsStatsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetGoodsStatsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetHiddenOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetHiddenOffersResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetMappingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetModelsOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetModelsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetModelsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferCardsContentStatusRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferCardsContentStatusResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferMappingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferMappingEntriesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferMappingsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferMappingsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferMappingsResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferRecommendationsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOfferRecommendationsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOrderBuyerInfoResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOrderLabelsDataResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOrderResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOrdersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOrdersStatsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOrdersStatsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOutletLicensesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOutletResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetOutletsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPriceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPriceWithDiscountDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPriceWithVatDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPricesByOfferIdsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPricesByOfferIdsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPricesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoAssortmentInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoBestsellerInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoConstraintsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoMechanicsInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoOffersResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromoPromocodeInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromosRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromosResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetPromosResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetQualityRatingDetailsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetQualityRatingRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetQualityRatingResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetQuarantineOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetQuarantineOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetQuarantineOffersResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetRegionWithChildrenResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetRegionsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetReportInfoResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetReturnResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetReturnsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetShipmentOrdersInfoResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetShipmentResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingEntriesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingEntriesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetWarehouseStocksDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GetWarehouseStocksRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/GetWarehouseStocksResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GetWarehousesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentAuthorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentAuthorType.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentListDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackDescriptionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackIdentifiersDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackListDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackMediaDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsFeedbackStatisticsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsStatsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsStatsGoodsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsStatsWarehouseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GoodsStatsWeightDimensionsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/GpsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/HiddenOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/LabelsSortingType.php create mode 100644 erp24/lib/yandex_market_api/Model/LanguageType.php create mode 100644 erp24/lib/yandex_market_api/Model/LicenseCheckStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/LicenseType.php create mode 100644 erp24/lib/yandex_market_api/Model/LogisticPickupPointDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/LogisticPointType.php create mode 100644 erp24/lib/yandex_market_api/Model/MappingsOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/MappingsOfferInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/MaxSaleQuantumDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/MechanicsType.php create mode 100644 erp24/lib/yandex_market_api/Model/ModelDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ModelInterface.php create mode 100644 erp24/lib/yandex_market_api/Model/ModelOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ModelPriceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ModelsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferAvailabilityStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferCampaignStatusDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferCampaignStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferCardDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferCardRecommendationDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferCardRecommendationType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferCardStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferCardsContentStatusDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferConditionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferConditionQualityType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferConditionType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferContentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferContentErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferContentErrorType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferForRecommendationDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferManualDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferMappingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferMappingEntriesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferMappingEntryDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferMappingErrorDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferMappingErrorType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferMappingInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferMappingKindType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferMappingSuggestionsListDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferParamDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferPriceByOfferIdsListResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferPriceByOfferIdsResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferPriceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferPriceListResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferPriceResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferProcessingNoteDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferProcessingNoteType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferProcessingStateDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferProcessingStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferRecommendationDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferRecommendationInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferRecommendationsResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferSellingProgramDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferSellingProgramStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferType.php create mode 100644 erp24/lib/yandex_market_api/Model/OfferWeightDimensionsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OffersDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OptionValuesLimitedDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBoxLayoutDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBoxLayoutItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBoxLayoutPartialCountDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBoxesLayoutDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBusinessBuyerDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBusinessDocumentsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBuyerBasicInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBuyerDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBuyerInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderBuyerType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderCancellationReasonType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderCourierDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryAddressDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryDateDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryDateReasonType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryDatesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryDispatchType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryEacType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryPartnerType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDeliveryType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDigitalItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderDocumentStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemDetailDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemInstanceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemInstanceModificationDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemInstanceType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemModificationDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemPromoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemSubsidyDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemSubsidyType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemTagType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemsModificationRequestReasonType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderItemsModificationResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderLabelDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderLiftType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderParcelBoxDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderPaymentMethodType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderPaymentType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderPromoType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderShipmentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderStateDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderStatsStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderStatusChangeDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderStatusChangeDeliveryDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderStatusChangeDeliveryDatesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderSubsidyDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderSubsidyType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderSubstatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderTaxSystemType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderTrackDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderUpdateStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrderVatType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersShipmentInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsCommissionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsCommissionType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsDeliveryRegionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsDetailsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsItemStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsOrderDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsOrderPaymentType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsPaymentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsPaymentOrderDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsPaymentSourceType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsPaymentType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsPriceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsPriceType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsStockType.php create mode 100644 erp24/lib/yandex_market_api/Model/OrdersStatsWarehouseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletAddressDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletDeliveryRuleDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletLicenseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletLicensesResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletType.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletVisibilityType.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletWorkingScheduleDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/OutletWorkingScheduleItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PageFormatType.php create mode 100644 erp24/lib/yandex_market_api/Model/PagedReturnsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PalletsCountDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ParameterType.php create mode 100644 erp24/lib/yandex_market_api/Model/ParameterValueConstraintsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ParameterValueDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ParameterValueOptionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ParcelBoxDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ParcelBoxLabelDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ParcelDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PartnerShipmentWarehouseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PaymentFrequencyType.php create mode 100644 erp24/lib/yandex_market_api/Model/PickupAddressDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PlacementType.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceCompetitivenessThresholdsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceCompetitivenessType.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictParamNameType.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictParameterDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictType.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceRecommendationItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceSuggestDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceSuggestOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PriceSuggestType.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoOfferAutoParticipatingDetailsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoOfferDiscountParamsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoOfferParamsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoOfferParticipationStatusFilterType.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoOfferParticipationStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoOfferPromocodeParamsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoOfferUpdateWarningCodeType.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoOfferUpdateWarningDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoParticipationType.php create mode 100644 erp24/lib/yandex_market_api/Model/PromoPeriodDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ProvideOrderDigitalCodesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/ProvideOrderItemIdentifiersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/ProvideOrderItemIdentifiersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/PutSkuBidsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/QualityRatingAffectedOrderDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/QualityRatingComponentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/QualityRatingComponentType.php create mode 100644 erp24/lib/yandex_market_api/Model/QualityRatingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/QualityRatingDetailsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/QuantumDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/QuarantineOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/RecipientType.php create mode 100644 erp24/lib/yandex_market_api/Model/RefundStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/RegionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/RegionType.php create mode 100644 erp24/lib/yandex_market_api/Model/RegionalModelInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/RejectedPromoOfferDeleteDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/RejectedPromoOfferDeleteReasonType.php create mode 100644 erp24/lib/yandex_market_api/Model/RejectedPromoOfferUpdateDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/RejectedPromoOfferUpdateReasonType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReportFormatType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReportInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ReportStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReportSubStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnDecisionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnDecisionReasonType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnDecisionSubreasonType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnDecisionType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnInstanceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnInstanceStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnInstanceStockType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnRequestDecisionType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnShipmentStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/ReturnType.php create mode 100644 erp24/lib/yandex_market_api/Model/ScrollingPagerDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/SearchModelsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/SearchShipmentsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SearchShipmentsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/SearchShipmentsResponseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/SellingProgramType.php create mode 100644 erp24/lib/yandex_market_api/Model/SendMessageToChatRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SetFeedParamsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SetOrderBoxLayoutRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SetOrderBoxLayoutResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/SetOrderDeliveryDateRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SetOrderDeliveryTrackCodeRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SetOrderShipmentBoxesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SetOrderShipmentBoxesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/SetReturnDecisionRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SetShipmentPalletsCountRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/ShelfsStatisticsAttributionType.php create mode 100644 erp24/lib/yandex_market_api/Model/ShipmentActionType.php create mode 100644 erp24/lib/yandex_market_api/Model/ShipmentBoxesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ShipmentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ShipmentInfoDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ShipmentPalletLabelPageFormatType.php create mode 100644 erp24/lib/yandex_market_api/Model/ShipmentStatusChangeDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ShipmentStatusType.php create mode 100644 erp24/lib/yandex_market_api/Model/ShipmentType.php create mode 100644 erp24/lib/yandex_market_api/Model/ShowsSalesGroupingType.php create mode 100644 erp24/lib/yandex_market_api/Model/SkipGoodsFeedbackReactionRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SkuBidItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/SkuBidRecommendationItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/SortOrderType.php create mode 100644 erp24/lib/yandex_market_api/Model/SuggestOfferPriceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/SuggestPricesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/SuggestPricesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/SuggestPricesResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/SuggestedOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/SuggestedOfferMappingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/TariffDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/TariffParameterDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/TariffType.php create mode 100644 erp24/lib/yandex_market_api/Model/TimePeriodDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/TimeUnitType.php create mode 100644 erp24/lib/yandex_market_api/Model/TrackDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/TransferOrdersFromShipmentRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/TurnoverDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/TurnoverType.php create mode 100644 erp24/lib/yandex_market_api/Model/UnitDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateBusinessOfferPriceDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateBusinessPricesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateCampaignOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateCampaignOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateMappingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateMappingsOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferContentRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferContentResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferContentResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferMappingDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferMappingEntryDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferMappingEntryRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferMappingResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferMappingsRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOfferMappingsResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOrderItemRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOrderStatusDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOrderStatusRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOrderStatusResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOrderStatusesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOrderStatusesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOrderStatusesResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOrderStorageLimitRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateOutletLicenseRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdatePriceWithDiscountDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdatePricesRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdatePromoOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdatePromoOfferDiscountParamsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdatePromoOfferParamsDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdatePromoOffersRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdatePromoOffersResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdatePromoOffersResultDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateStockDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateStockItemDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateStocksRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/UpdateTimeDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/ValueRestrictionDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/VerifyOrderEacRequest.php create mode 100644 erp24/lib/yandex_market_api/Model/VerifyOrderEacResponse.php create mode 100644 erp24/lib/yandex_market_api/Model/WarehouseAddressDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/WarehouseDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/WarehouseGroupDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/WarehouseOfferDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/WarehouseOffersDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/WarehouseStockDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/WarehouseStockType.php create mode 100644 erp24/lib/yandex_market_api/Model/WarehousesDTO.php create mode 100644 erp24/lib/yandex_market_api/Model/WarningPromoOfferUpdateDTO.php create mode 100644 erp24/lib/yandex_market_api/ObjectSerializer.php delete mode 100644 sql diff --git a/FETCH_HEAD b/FETCH_HEAD deleted file mode 100644 index e69de29b..00000000 diff --git a/erp24/api2/controllers/YandexMarketController.php b/erp24/api2/controllers/YandexMarketController.php new file mode 100644 index 00000000..741eacfb --- /dev/null +++ b/erp24/api2/controllers/YandexMarketController.php @@ -0,0 +1,183 @@ +response->format = \yii\web\Response::FORMAT_JSON; + + + $config = Configuration::getDefaultConfiguration()->setApiKey('Api-Key', 'ACMA:r3sa2VyjkgcO0aOxGoyAWuGH15g5mWAqXRMuylVA:a0bccb7e'); + +// $apiInstance = new Api\CampaignsApi( +// new GuzzleHttp\Client(), +// $config +// ); +// +// return $apiInstance->getCampaigns(); + +// $apiInstance = new Api\CategoriesApi( +// new GuzzleHttp\Client(), +// $config +// ); +// +// return $apiInstance->getCategoriesTree(); + +// $apiInstance = new Api\ContentApi( +// new GuzzleHttp\Client(), +// $config +// ); +// +// return $apiInstance->getCategoryContentParameters(91284); + +// $apiInstance = new Api\HiddenOffersApi(new GuzzleHttp\Client(), $config); +// $add_hidden_offers_request = [ +// "hiddenOffers" => [ +// [ +// "offerId" => "b78e518d-7504-11ee-84e0-ac1f6b1b7573", +// ], +// [ +// "offerId" => "558783c6-4a97-11ee-933f-b42e991aff6c", +// ], +// ] +// ]; +// return $apiInstance->addHiddenOffers(109969229, $add_hidden_offers_request); + +// $apiInstance = new Api\StocksApi(new GuzzleHttp\Client(), $config); +// $update_stocks_request = [ +// "skus" => [ +// [ +// "sku" => "b78e518d-7504-11ee-84e0-ac1f6b1b7573", +// "items" => [ +// [ +// "count" => 2, +// "updatedAt" => date("c"), +// ] +// ] +// ], +// [ +// "sku" => "558783c6-4a97-11ee-933f-b42e991aff6c", +// "items" => [ +// [ +// "count" => 3, +// "updatedAt" => date("c"), +// ] +// ] +// ] +// ], +// ]; +// return $apiInstance->updateStocks(109969229, $update_stocks_request); + + $products = Products1c::find()->alias('p')->leftJoin('products_class pc', 'p.parent_id = pc.category_id') + ->where(['pc.tip' => 'marketplace'])->all(); + $models = []; + foreach ($products as $product) { + /* @var $product Products1c */ + $models []= new Model\UpdateOfferMappingDTO([ + 'offer' => [ + 'offerId' => $product->id, + 'category' => 'Цветы', + 'marketCategoryId' => '91284', + 'name' => $product->name, + 'basicPrice' => [ + 'currencyId' => Model\CurrencyType::RUR, + 'value' => 2000 + rand(0, 1000), + ], + 'vendor' => 'База Цветов 24', + 'weightDimensions' => [ + 'height' => 40, + 'length' => 23, + 'weight' => 0.15, + 'width' => 20, + ], + 'description' => ' +Нежное сочетание хризантем и розовых гербер в этом оформлении создаёт гармонию и яркое настроение. Идеально для поздравлений и особых случаев, когда хочется подчеркнуть свою заботу и внимание. Этот ансамбль привнесёт радость и свежесть в любой момент. + +Советы по уходу за цветами: +1) Меняйте воду в вазе каждые 2 дня. +2) Обрезайте стебли под углом перед погружением в воду. +3) Держите букет вдали от прямых солнечных лучей и сквозняков. +', + 'pictures' => ['https://bazacvetov24.ru/products/8608/buket-glyantsevoe-roze-zakazat-s-dostavkoy_9773_lg.jpg'], + ], + ]); + } + + $apiInstance = new Api\BusinessOfferMappingsApi( + new GuzzleHttp\Client(), + $config + ); + + $apiModel = new Model\UpdateOfferMappingsRequest; + $apiModel->setOfferMappings($models); +// $apiModel->setOfferMappings([ +// new Model\UpdateOfferMappingDTO([ +// 'offer' => [ +// 'offerId' => 'b78e518d-7504-11ee-84e0-ac1f6b1b7573', +// 'category' => 'Цветы', +// 'marketCategoryId' => '91284', +// 'name' => 'МБ57(н)', +// 'basicPrice' => [ +// 'currencyId' => Model\CurrencyType::RUR, +// 'value' => 2000, +// ], +// 'vendor' => 'База Цветов 24', +// 'weightDimensions' => [ +// 'height' => 40, +// 'length' => 23, +// 'weight' => 0.15, +// 'width' => 20, +// ], +// 'description' => ' +//Нежное сочетание хризантем и розовых гербер в этом оформлении создаёт гармонию и яркое настроение. Идеально для поздравлений и особых случаев, когда хочется подчеркнуть свою заботу и внимание. Этот ансамбль привнесёт радость и свежесть в любой момент. +// +//Советы по уходу за цветами: +//1) Меняйте воду в вазе каждые 2 дня. +//2) Обрезайте стебли под углом перед погружением в воду. +//3) Держите букет вдали от прямых солнечных лучей и сквозняков. +//', +// 'pictures' => ['https://bazacvetov24.ru/products/8608/buket-glyantsevoe-roze-zakazat-s-dostavkoy_9773_lg.jpg'], +// ], +// ]), +// new Model\UpdateOfferMappingDTO([ +// 'offer' => [ +// 'offerId' => '558783c6-4a97-11ee-933f-b42e991aff6c', +// 'category' => 'Цветы', +// 'marketCategoryId' => '91284', +// 'name' => 'МБ35(н)', +// 'basicPrice' => [ +// 'currencyId' => Model\CurrencyType::RUR, +// 'value' => 3000, +// ], +// 'vendor' => 'База Цветов 24', +// 'weightDimensions' => [ +// 'height' => 40, +// 'length' => 23, +// 'weight' => 0.15, +// 'width' => 20, +// ], +// 'description' => ' +//Букет из 9 розовых лизиантусов — утончённое сочетание нежности и изящества. Эти цветы символизируют искренность чувств и заботу, делая их идеальным выбором для любого важного события или просто для создания радостного настроения. +// +//Советы по уходу за цветами: +//1) Регулярно меняйте воду: Обновляйте воду в вазе каждые 1-2 дня. +//2) Каждый раз перед сменой воды подрезайте стебли на 1-2 см под углом. +//3) Держите цветы вдали от прямых солнечных лучей и сквозняков. +//', +// 'pictures' => ['https://bazacvetov24.ru/products/8878/9-rozovykh-liziantusov_11248_lg.jpg'], +// ], +// ]), +// ]); + + return $apiInstance->updateoffermappings(5330887, $apiModel); + } +} \ No newline at end of file diff --git a/erp24/composer.json b/erp24/composer.json index d1f2c033..d8d2dae3 100644 --- a/erp24/composer.json +++ b/erp24/composer.json @@ -14,13 +14,16 @@ }, "minimum-stability": "stable", "require": { - "php": ">=7.4.0", + "php": "^8.1", "yiisoft/yii2": "~2.0.45", "yiisoft/yii2-symfonymailer": "~2.0.3", "ext-json": "*", + "ext-curl": "*", + "ext-mbstring": "*", "yiisoft/yii2-queue": "^2.3", "ext-gd": "*", - "guzzlehttp/guzzle": "^7.0", + "guzzlehttp/guzzle": "^7.3", + "guzzlehttp/psr7": "^1.7 || ^2.0", "mauricesvay/php-facedetection": "*", "wbraganca/yii2-dynamicform": "dev-master", "unclead/yii2-multiple-input": "~2.0", @@ -38,6 +41,7 @@ "yiisoft/yii2-gii": "~2.2.0", "yiisoft/yii2-faker": "~2.0.0", "phpunit/phpunit": "~9.5.0", + "friendsofphp/php-cs-fixer": "^3.5", "codeception/codeception": "^5.0.0 || ^4.0", "codeception/lib-innerbrowser": "^4.0 || ^3.0 || ^1.1", "codeception/module-asserts": "^3.0 || ^1.1", @@ -51,6 +55,9 @@ "2amigos/yii2-date-picker-widget" : "~1.0", "2amigos/qrcode-library": "^2.0" }, + "autoload": { + "psr-4": { "OpenAPI\\Client\\" : "lib/yandex_market_api/" } + }, "config": { "allow-plugins": { "yiisoft/yii2-composer" : true diff --git a/erp24/lib/yandex_market_api/Api/BidsApi.php b/erp24/lib/yandex_market_api/Api/BidsApi.php new file mode 100644 index 00000000..c9b06bea --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/BidsApi.php @@ -0,0 +1,2372 @@ + [ + 'application/json', + ], + 'getBidsRecommendations' => [ + 'application/json', + ], + 'putBidsForBusiness' => [ + 'application/json', + ], + 'putBidsForCampaign' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getBidsInfoForBusiness + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsInfoForBusiness($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness'][0]) + { + list($response) = $this->getBidsInfoForBusinessWithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + return $response; + } + + /** + * Operation getBidsInfoForBusinessWithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsInfoForBusinessWithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness'][0]) + { + $request = $this->getBidsInfoForBusinessRequest($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsInfoForBusinessAsync + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusinessAsync($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness'][0]) + { + return $this->getBidsInfoForBusinessAsyncWithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsInfoForBusinessAsyncWithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusinessAsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + $request = $this->getBidsInfoForBusinessRequest($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsInfoForBusiness' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsInfoForBusinessRequest($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsInfoForBusiness' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BidsApi.getBidsInfoForBusiness, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/bids/info'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_info_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_info_request)); + } else { + $httpBody = $get_bids_info_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsRecommendations + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsRecommendations($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations'][0]) + { + list($response) = $this->getBidsRecommendationsWithHttpInfo($business_id, $get_bids_recommendations_request, $contentType); + return $response; + } + + /** + * Operation getBidsRecommendationsWithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsRecommendationsWithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations'][0]) + { + $request = $this->getBidsRecommendationsRequest($business_id, $get_bids_recommendations_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsRecommendationsAsync + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendationsAsync($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations'][0]) + { + return $this->getBidsRecommendationsAsyncWithHttpInfo($business_id, $get_bids_recommendations_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsRecommendationsAsyncWithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendationsAsyncWithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + $request = $this->getBidsRecommendationsRequest($business_id, $get_bids_recommendations_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsRecommendations' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsRecommendationsRequest($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsRecommendations' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BidsApi.getBidsRecommendations, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_bids_recommendations_request' is set + if ($get_bids_recommendations_request === null || (is_array($get_bids_recommendations_request) && count($get_bids_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_bids_recommendations_request when calling getBidsRecommendations' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_recommendations_request)); + } else { + $httpBody = $get_bids_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForBusiness + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForBusiness($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness'][0]) + { + list($response) = $this->putBidsForBusinessWithHttpInfo($business_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForBusinessWithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForBusinessWithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness'][0]) + { + $request = $this->putBidsForBusinessRequest($business_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForBusinessAsync + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusinessAsync($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness'][0]) + { + return $this->putBidsForBusinessAsyncWithHttpInfo($business_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForBusinessAsyncWithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusinessAsyncWithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForBusinessRequest($business_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForBusiness' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForBusinessRequest($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling putBidsForBusiness' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BidsApi.putBidsForBusiness, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForBusiness' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForCampaign + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForCampaign($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign'][0]) + { + list($response) = $this->putBidsForCampaignWithHttpInfo($campaign_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForCampaignWithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForCampaignWithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign'][0]) + { + $request = $this->putBidsForCampaignRequest($campaign_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForCampaignAsync + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaignAsync($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign'][0]) + { + return $this->putBidsForCampaignAsyncWithHttpInfo($campaign_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForCampaignAsyncWithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaignAsyncWithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForCampaignRequest($campaign_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForCampaign' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForCampaignRequest($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling putBidsForCampaign' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling BidsApi.putBidsForCampaign, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForCampaign' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/BusinessOfferMappingsApi.php b/erp24/lib/yandex_market_api/Api/BusinessOfferMappingsApi.php new file mode 100644 index 00000000..86c9b3c7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/BusinessOfferMappingsApi.php @@ -0,0 +1,3610 @@ + [ + 'application/json', + ], + 'deleteOffers' => [ + 'application/json', + ], + 'deleteOffersFromArchive' => [ + 'application/json', + ], + 'getOfferMappings' => [ + 'application/json', + ], + 'getSuggestedOfferMappings' => [ + 'application/json', + ], + 'updateOfferMappings' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addOffersToArchive + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addOffersToArchive($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive'][0]) + { + list($response) = $this->addOffersToArchiveWithHttpInfo($business_id, $add_offers_to_archive_request, $contentType); + return $response; + } + + /** + * Operation addOffersToArchiveWithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addOffersToArchiveWithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive'][0]) + { + $request = $this->addOffersToArchiveRequest($business_id, $add_offers_to_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\AddOffersToArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\AddOffersToArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addOffersToArchiveAsync + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchiveAsync($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive'][0]) + { + return $this->addOffersToArchiveAsyncWithHttpInfo($business_id, $add_offers_to_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addOffersToArchiveAsyncWithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchiveAsyncWithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive'][0]) + { + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + $request = $this->addOffersToArchiveRequest($business_id, $add_offers_to_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addOffersToArchive' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addOffersToArchiveRequest($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling addOffersToArchive' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BusinessOfferMappingsApi.addOffersToArchive, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_offers_to_archive_request' is set + if ($add_offers_to_archive_request === null || (is_array($add_offers_to_archive_request) && count($add_offers_to_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_offers_to_archive_request when calling addOffersToArchive' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/archive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_offers_to_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_offers_to_archive_request)); + } else { + $httpBody = $add_offers_to_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffers + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffers($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers'][0]) + { + list($response) = $this->deleteOffersWithHttpInfo($business_id, $delete_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteOffersWithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffersWithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers'][0]) + { + $request = $this->deleteOffersRequest($business_id, $delete_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffersAsync + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersAsync($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers'][0]) + { + return $this->deleteOffersAsyncWithHttpInfo($business_id, $delete_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffersAsyncWithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersAsyncWithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + $request = $this->deleteOffersRequest($business_id, $delete_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffers' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffersRequest($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffers' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BusinessOfferMappingsApi.deleteOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_request' is set + if ($delete_offers_request === null || (is_array($delete_offers_request) && count($delete_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_request when calling deleteOffers' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_request)); + } else { + $httpBody = $delete_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffersFromArchive + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffersFromArchive($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive'][0]) + { + list($response) = $this->deleteOffersFromArchiveWithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType); + return $response; + } + + /** + * Operation deleteOffersFromArchiveWithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffersFromArchiveWithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive'][0]) + { + $request = $this->deleteOffersFromArchiveRequest($business_id, $delete_offers_from_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffersFromArchiveAsync + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchiveAsync($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive'][0]) + { + return $this->deleteOffersFromArchiveAsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffersFromArchiveAsyncWithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchiveAsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + $request = $this->deleteOffersFromArchiveRequest($business_id, $delete_offers_from_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffersFromArchive' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffersFromArchiveRequest($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffersFromArchive' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BusinessOfferMappingsApi.deleteOffersFromArchive, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_from_archive_request' is set + if ($delete_offers_from_archive_request === null || (is_array($delete_offers_from_archive_request) && count($delete_offers_from_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_from_archive_request when calling deleteOffersFromArchive' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/unarchive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_from_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_from_archive_request)); + } else { + $httpBody = $delete_offers_from_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappings + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferMappings($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings'][0]) + { + list($response) = $this->getOfferMappingsWithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getOfferMappingsWithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferMappingsWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings'][0]) + { + $request = $this->getOfferMappingsRequest($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappingsAsync + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappingsAsync($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings'][0]) + { + return $this->getOfferMappingsAsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappingsAsyncWithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappingsAsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + $request = $this->getOfferMappingsRequest($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappings' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferMappingsRequest($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferMappings' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BusinessOfferMappingsApi.getOfferMappings, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-mappings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_mappings_request)); + } else { + $httpBody = $get_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappings + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getSuggestedOfferMappings($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings'][0]) + { + list($response) = $this->getSuggestedOfferMappingsWithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappingsWithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getSuggestedOfferMappingsWithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings'][0]) + { + $request = $this->getSuggestedOfferMappingsRequest($business_id, $get_suggested_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappingsAsync + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappingsAsync($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings'][0]) + { + return $this->getSuggestedOfferMappingsAsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappingsAsyncWithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappingsAsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + $request = $this->getSuggestedOfferMappingsRequest($business_id, $get_suggested_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappings' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getSuggestedOfferMappingsRequest($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getSuggestedOfferMappings' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BusinessOfferMappingsApi.getSuggestedOfferMappings, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/offer-mappings/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mappings_request)); + } else { + $httpBody = $get_suggested_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappings + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferMappings($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings'][0]) + { + list($response) = $this->updateOfferMappingsWithHttpInfo($business_id, $update_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappingsWithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferMappingsWithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings'][0]) + { + $request = $this->updateOfferMappingsRequest($business_id, $update_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappingsAsync + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappingsAsync($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings'][0]) + { + return $this->updateOfferMappingsAsyncWithHttpInfo($business_id, $update_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappingsAsyncWithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappingsAsyncWithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + $request = $this->updateOfferMappingsRequest($business_id, $update_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappings' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferMappingsRequest($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferMappings' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BusinessOfferMappingsApi.updateOfferMappings, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mappings_request' is set + if ($update_offer_mappings_request === null || (is_array($update_offer_mappings_request) && count($update_offer_mappings_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mappings_request when calling updateOfferMappings' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mappings_request)); + } else { + $httpBody = $update_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/BusinessesApi.php b/erp24/lib/yandex_market_api/Api/BusinessesApi.php new file mode 100644 index 00000000..c1c0b6ec --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/BusinessesApi.php @@ -0,0 +1,673 @@ + [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getBusinessSettings + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessSettings($business_id, string $contentType = self::contentTypes['getBusinessSettings'][0]) + { + list($response) = $this->getBusinessSettingsWithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getBusinessSettingsWithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessSettingsWithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings'][0]) + { + $request = $this->getBusinessSettingsRequest($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessSettingsAsync + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettingsAsync($business_id, string $contentType = self::contentTypes['getBusinessSettings'][0]) + { + return $this->getBusinessSettingsAsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessSettingsAsyncWithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettingsAsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + $request = $this->getBusinessSettingsRequest($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessSettings' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessSettingsRequest($business_id, string $contentType = self::contentTypes['getBusinessSettings'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessSettings' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling BusinessesApi.getBusinessSettings, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/CampaignsApi.php b/erp24/lib/yandex_market_api/Api/CampaignsApi.php new file mode 100644 index 00000000..4b1467d9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/CampaignsApi.php @@ -0,0 +1,3383 @@ + [ + 'application/json', + ], + 'getCampaignLogins' => [ + 'application/json', + ], + 'getCampaignRegion' => [ + 'application/json', + ], + 'getCampaignSettings' => [ + 'application/json', + ], + 'getCampaigns' => [ + 'application/json', + ], + 'getCampaignsByLogin' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getCampaign + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaign($campaign_id, string $contentType = self::contentTypes['getCampaign'][0]) + { + list($response) = $this->getCampaignWithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignWithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign'][0]) + { + $request = $this->getCampaignRequest($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignAsync + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignAsync($campaign_id, string $contentType = self::contentTypes['getCampaign'][0]) + { + return $this->getCampaignAsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignAsyncWithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignAsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + $request = $this->getCampaignRequest($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaign' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignRequest($campaign_id, string $contentType = self::contentTypes['getCampaign'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaign' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling CampaignsApi.getCampaign, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignLogins + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignLogins($campaign_id, string $contentType = self::contentTypes['getCampaignLogins'][0]) + { + list($response) = $this->getCampaignLoginsWithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignLoginsWithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignLoginsWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins'][0]) + { + $request = $this->getCampaignLoginsRequest($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignLoginsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignLoginsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignLoginsAsync + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLoginsAsync($campaign_id, string $contentType = self::contentTypes['getCampaignLogins'][0]) + { + return $this->getCampaignLoginsAsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignLoginsAsyncWithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLoginsAsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + $request = $this->getCampaignLoginsRequest($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignLogins' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignLoginsRequest($campaign_id, string $contentType = self::contentTypes['getCampaignLogins'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignLogins' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling CampaignsApi.getCampaignLogins, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/logins'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignRegion + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getCampaignRegion($campaign_id, string $contentType = self::contentTypes['getCampaignRegion'][0]) + { + list($response) = $this->getCampaignRegionWithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignRegionWithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getCampaignRegionWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion'][0]) + { + $request = $this->getCampaignRegionRequest($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignRegionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignRegionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignRegionAsync + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegionAsync($campaign_id, string $contentType = self::contentTypes['getCampaignRegion'][0]) + { + return $this->getCampaignRegionAsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignRegionAsyncWithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegionAsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + $request = $this->getCampaignRegionRequest($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignRegion' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getCampaignRegionRequest($campaign_id, string $contentType = self::contentTypes['getCampaignRegion'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignRegion' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling CampaignsApi.getCampaignRegion, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/region'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignSettings + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignSettings($campaign_id, string $contentType = self::contentTypes['getCampaignSettings'][0]) + { + list($response) = $this->getCampaignSettingsWithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignSettingsWithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignSettingsWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings'][0]) + { + $request = $this->getCampaignSettingsRequest($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignSettingsAsync + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettingsAsync($campaign_id, string $contentType = self::contentTypes['getCampaignSettings'][0]) + { + return $this->getCampaignSettingsAsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignSettingsAsyncWithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettingsAsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + $request = $this->getCampaignSettingsRequest($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignSettings' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignSettingsRequest($campaign_id, string $contentType = self::contentTypes['getCampaignSettings'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignSettings' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling CampaignsApi.getCampaignSettings, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaigns + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaigns($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns'][0]) + { + list($response) = $this->getCampaignsWithHttpInfo($page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaignsWithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignsWithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns'][0]) + { + $request = $this->getCampaignsRequest($page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignsAsync + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsAsync($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns'][0]) + { + return $this->getCampaignsAsyncWithHttpInfo($page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignsAsyncWithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsAsyncWithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaignsRequest($page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaigns' + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignsRequest($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns'][0]) + { + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling CampaignsApi.getCampaigns, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignsByLogin + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignsByLogin($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin'][0]) + { + list($response) = $this->getCampaignsByLoginWithHttpInfo($login, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaignsByLoginWithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignsByLoginWithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin'][0]) + { + $request = $this->getCampaignsByLoginRequest($login, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignsByLoginAsync + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLoginAsync($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin'][0]) + { + return $this->getCampaignsByLoginAsyncWithHttpInfo($login, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignsByLoginAsyncWithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLoginAsyncWithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaignsByLoginRequest($login, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignsByLogin' + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignsByLoginRequest($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin'][0]) + { + + // verify the required parameter 'login' is set + if ($login === null || (is_array($login) && count($login) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $login when calling getCampaignsByLogin' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling CampaignsApi.getCampaignsByLogin, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/by_login/{login}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($login !== null) { + $resourcePath = str_replace( + '{' . 'login' . '}', + ObjectSerializer::toPathValue($login), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/CategoriesApi.php b/erp24/lib/yandex_market_api/Api/CategoriesApi.php new file mode 100644 index 00000000..247561a6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/CategoriesApi.php @@ -0,0 +1,1192 @@ + [ + 'application/json', + ], + 'getCategoriesTree' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getCategoriesMaxSaleQuantum + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesMaxSaleQuantum($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum'][0]) + { + list($response) = $this->getCategoriesMaxSaleQuantumWithHttpInfo($get_categories_max_sale_quantum_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesMaxSaleQuantumWithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesMaxSaleQuantumWithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum'][0]) + { + $request = $this->getCategoriesMaxSaleQuantumRequest($get_categories_max_sale_quantum_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesMaxSaleQuantumAsync + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantumAsync($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum'][0]) + { + return $this->getCategoriesMaxSaleQuantumAsyncWithHttpInfo($get_categories_max_sale_quantum_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesMaxSaleQuantumAsyncWithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantumAsyncWithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + $request = $this->getCategoriesMaxSaleQuantumRequest($get_categories_max_sale_quantum_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesMaxSaleQuantum' + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesMaxSaleQuantumRequest($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum'][0]) + { + + // verify the required parameter 'get_categories_max_sale_quantum_request' is set + if ($get_categories_max_sale_quantum_request === null || (is_array($get_categories_max_sale_quantum_request) && count($get_categories_max_sale_quantum_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_categories_max_sale_quantum_request when calling getCategoriesMaxSaleQuantum' + ); + } + + + $resourcePath = '/categories/max-sale-quantum'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_max_sale_quantum_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_max_sale_quantum_request)); + } else { + $httpBody = $get_categories_max_sale_quantum_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesTree + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesTree($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree'][0]) + { + list($response) = $this->getCategoriesTreeWithHttpInfo($get_categories_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesTreeWithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesTreeWithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree'][0]) + { + $request = $this->getCategoriesTreeRequest($get_categories_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesTreeAsync + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTreeAsync($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree'][0]) + { + return $this->getCategoriesTreeAsyncWithHttpInfo($get_categories_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesTreeAsyncWithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTreeAsyncWithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + $request = $this->getCategoriesTreeRequest($get_categories_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesTree' + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesTreeRequest($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree'][0]) + { + + + + $resourcePath = '/categories/tree'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_request)); + } else { + $httpBody = $get_categories_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/ChatsApi.php b/erp24/lib/yandex_market_api/Api/ChatsApi.php new file mode 100644 index 00000000..1c386c85 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/ChatsApi.php @@ -0,0 +1,3037 @@ + [ + 'application/json', + ], + 'getChatHistory' => [ + 'application/json', + ], + 'getChats' => [ + 'application/json', + ], + 'sendFileToChat' => [ + 'multipart/form-data', + ], + 'sendMessageToChat' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation createChat + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function createChat($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat'][0]) + { + list($response) = $this->createChatWithHttpInfo($business_id, $create_chat_request, $contentType); + return $response; + } + + /** + * Operation createChatWithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function createChatWithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat'][0]) + { + $request = $this->createChatRequest($business_id, $create_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CreateChatResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CreateChatResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CreateChatResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CreateChatResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createChatAsync + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChatAsync($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat'][0]) + { + return $this->createChatAsyncWithHttpInfo($business_id, $create_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createChatAsyncWithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChatAsyncWithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat'][0]) + { + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + $request = $this->createChatRequest($business_id, $create_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createChat' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createChatRequest($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling createChat' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ChatsApi.createChat, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'create_chat_request' is set + if ($create_chat_request === null || (is_array($create_chat_request) && count($create_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $create_chat_request when calling createChat' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/new'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($create_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($create_chat_request)); + } else { + $httpBody = $create_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChatHistory + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChatHistory($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory'][0]) + { + list($response) = $this->getChatHistoryWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChatHistoryWithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChatHistoryWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory'][0]) + { + $request = $this->getChatHistoryRequest($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatHistoryResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatHistoryResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChatHistoryAsync + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistoryAsync($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory'][0]) + { + return $this->getChatHistoryAsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChatHistoryAsyncWithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistoryAsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + $request = $this->getChatHistoryRequest($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChatHistory' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChatHistoryRequest($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChatHistory' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ChatsApi.getChatHistory, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling getChatHistory' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling ChatsApi.getChatHistory, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chat_history_request' is set + if ($get_chat_history_request === null || (is_array($get_chat_history_request) && count($get_chat_history_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chat_history_request when calling getChatHistory' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chat_history_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chat_history_request)); + } else { + $httpBody = $get_chat_history_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChats + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChats($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats'][0]) + { + list($response) = $this->getChatsWithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChatsWithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChatsWithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats'][0]) + { + $request = $this->getChatsRequest($business_id, $get_chats_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChatsAsync + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatsAsync($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats'][0]) + { + return $this->getChatsAsyncWithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChatsAsyncWithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatsAsyncWithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + $request = $this->getChatsRequest($business_id, $get_chats_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChats' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChatsRequest($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChats' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ChatsApi.getChats, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chats_request' is set + if ($get_chats_request === null || (is_array($get_chats_request) && count($get_chats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chats_request when calling getChats' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chats_request)); + } else { + $httpBody = $get_chats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendFileToChat + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendFileToChat($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat'][0]) + { + list($response) = $this->sendFileToChatWithHttpInfo($business_id, $chat_id, $file, $contentType); + return $response; + } + + /** + * Operation sendFileToChatWithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendFileToChatWithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat'][0]) + { + $request = $this->sendFileToChatRequest($business_id, $chat_id, $file, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendFileToChatAsync + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChatAsync($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat'][0]) + { + return $this->sendFileToChatAsyncWithHttpInfo($business_id, $chat_id, $file, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendFileToChatAsyncWithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChatAsyncWithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendFileToChatRequest($business_id, $chat_id, $file, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendFileToChat' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendFileToChatRequest($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendFileToChat' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ChatsApi.sendFileToChat, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendFileToChat' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling ChatsApi.sendFileToChat, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'file' is set + if ($file === null || (is_array($file) && count($file) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $file when calling sendFileToChat' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/file/send'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + // form params + if ($file !== null) { + $multipart = true; + $formParams['file'] = []; + $paramFiles = is_array($file) ? $file : [$file]; + foreach ($paramFiles as $paramFile) { + $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( + ObjectSerializer::toFormValue($paramFile), + 'rb' + ); + } + } + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendMessageToChat + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendMessageToChat($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat'][0]) + { + list($response) = $this->sendMessageToChatWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType); + return $response; + } + + /** + * Operation sendMessageToChatWithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendMessageToChatWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat'][0]) + { + $request = $this->sendMessageToChatRequest($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendMessageToChatAsync + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChatAsync($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat'][0]) + { + return $this->sendMessageToChatAsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendMessageToChatAsyncWithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChatAsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendMessageToChatRequest($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendMessageToChat' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendMessageToChatRequest($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendMessageToChat' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ChatsApi.sendMessageToChat, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendMessageToChat' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling ChatsApi.sendMessageToChat, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'send_message_to_chat_request' is set + if ($send_message_to_chat_request === null || (is_array($send_message_to_chat_request) && count($send_message_to_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $send_message_to_chat_request when calling sendMessageToChat' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/message'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($send_message_to_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($send_message_to_chat_request)); + } else { + $httpBody = $send_message_to_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/ContentApi.php b/erp24/lib/yandex_market_api/Api/ContentApi.php new file mode 100644 index 00000000..5ce7d940 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/ContentApi.php @@ -0,0 +1,1836 @@ + [ + 'application/json', + ], + 'getOfferCardsContentStatus' => [ + 'application/json', + ], + 'updateOfferContent' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getCategoryContentParameters + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoryContentParameters($category_id, string $contentType = self::contentTypes['getCategoryContentParameters'][0]) + { + list($response) = $this->getCategoryContentParametersWithHttpInfo($category_id, $contentType); + return $response; + } + + /** + * Operation getCategoryContentParametersWithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoryContentParametersWithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters'][0]) + { + $request = $this->getCategoryContentParametersRequest($category_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoryContentParametersAsync + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParametersAsync($category_id, string $contentType = self::contentTypes['getCategoryContentParameters'][0]) + { + return $this->getCategoryContentParametersAsyncWithHttpInfo($category_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoryContentParametersAsyncWithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParametersAsyncWithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + $request = $this->getCategoryContentParametersRequest($category_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoryContentParameters' + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoryContentParametersRequest($category_id, string $contentType = self::contentTypes['getCategoryContentParameters'][0]) + { + + // verify the required parameter 'category_id' is set + if ($category_id === null || (is_array($category_id) && count($category_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $category_id when calling getCategoryContentParameters' + ); + } + if ($category_id < 1) { + throw new \InvalidArgumentException('invalid value for "$category_id" when calling ContentApi.getCategoryContentParameters, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/category/{categoryId}/parameters'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($category_id !== null) { + $resourcePath = str_replace( + '{' . 'categoryId' . '}', + ObjectSerializer::toPathValue($category_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferCardsContentStatus + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferCardsContentStatus($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus'][0]) + { + list($response) = $this->getOfferCardsContentStatusWithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + return $response; + } + + /** + * Operation getOfferCardsContentStatusWithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferCardsContentStatusWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus'][0]) + { + $request = $this->getOfferCardsContentStatusRequest($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferCardsContentStatusAsync + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatusAsync($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus'][0]) + { + return $this->getOfferCardsContentStatusAsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferCardsContentStatusAsyncWithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatusAsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + $request = $this->getOfferCardsContentStatusRequest($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferCardsContentStatus' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferCardsContentStatusRequest($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferCardsContentStatus' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ContentApi.getOfferCardsContentStatus, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-cards'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_cards_content_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_cards_content_status_request)); + } else { + $httpBody = $get_offer_cards_content_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferContent + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferContent($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent'][0]) + { + list($response) = $this->updateOfferContentWithHttpInfo($business_id, $update_offer_content_request, $contentType); + return $response; + } + + /** + * Operation updateOfferContentWithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferContentWithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent'][0]) + { + $request = $this->updateOfferContentRequest($business_id, $update_offer_content_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferContentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferContentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferContentAsync + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContentAsync($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent'][0]) + { + return $this->updateOfferContentAsyncWithHttpInfo($business_id, $update_offer_content_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferContentAsyncWithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContentAsyncWithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + $request = $this->updateOfferContentRequest($business_id, $update_offer_content_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferContent' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferContentRequest($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferContent' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ContentApi.updateOfferContent, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_content_request' is set + if ($update_offer_content_request === null || (is_array($update_offer_content_request) && count($update_offer_content_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_content_request when calling updateOfferContent' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-cards/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_content_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_content_request)); + } else { + $httpBody = $update_offer_content_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/DbsApi.php b/erp24/lib/yandex_market_api/Api/DbsApi.php new file mode 100644 index 00000000..8b83e707 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/DbsApi.php @@ -0,0 +1,70501 @@ + [ + 'application/json', + ], + 'addHiddenOffers_2' => [ + 'application/json', + ], + 'addOffersToArchive_0' => [ + 'application/json', + ], + 'calculateTariffs_2' => [ + 'application/json', + ], + 'confirmBusinessPrices_0' => [ + 'application/json', + ], + 'confirmCampaignPrices_0' => [ + 'application/json', + ], + 'createChat_0' => [ + 'application/json', + ], + 'createOutlet_0' => [ + 'application/json', + ], + 'deleteCampaignOffers_0' => [ + 'application/json', + ], + 'deleteGoodsFeedbackComment_2' => [ + 'application/json', + ], + 'deleteHiddenOffers_2' => [ + 'application/json', + ], + 'deleteOffersFromArchive_0' => [ + 'application/json', + ], + 'deleteOffers_0' => [ + 'application/json', + ], + 'deleteOutletLicenses_0' => [ + 'application/json', + ], + 'deleteOutlet_0' => [ + 'application/json', + ], + 'deletePromoOffers_2' => [ + 'application/json', + ], + 'generateBoostConsolidatedReport_2' => [ + 'application/json', + ], + 'generateCompetitorsPositionReport_1' => [ + 'application/json', + ], + 'generateGoodsFeedbackReport_2' => [ + 'application/json', + ], + 'generateMassOrderLabelsReport_1' => [ + 'application/json', + ], + 'generateOrderLabel_1' => [ + 'application/json', + ], + 'generateOrderLabels_1' => [ + 'application/json', + ], + 'generatePricesReport_2' => [ + 'application/json', + ], + 'generateShelfsStatisticsReport_2' => [ + 'application/json', + ], + 'generateShowsSalesReport_1' => [ + 'application/json', + ], + 'generateStocksOnWarehousesReport_2' => [ + 'application/json', + ], + 'generateUnitedMarketplaceServicesReport_1' => [ + 'application/json', + ], + 'generateUnitedNettingReport_1' => [ + 'application/json', + ], + 'generateUnitedOrdersReport_2' => [ + 'application/json', + ], + 'getAllOffers_0' => [ + 'application/json', + ], + 'getBidsInfoForBusiness_0' => [ + 'application/json', + ], + 'getBidsRecommendations_0' => [ + 'application/json', + ], + 'getBusinessQuarantineOffers_0' => [ + 'application/json', + ], + 'getBusinessSettings_0' => [ + 'application/json', + ], + 'getCampaignLogins_0' => [ + 'application/json', + ], + 'getCampaignOffers_0' => [ + 'application/json', + ], + 'getCampaignQuarantineOffers_0' => [ + 'application/json', + ], + 'getCampaignRegion_0' => [ + 'application/json', + ], + 'getCampaignSettings_0' => [ + 'application/json', + ], + 'getCampaign_0' => [ + 'application/json', + ], + 'getCampaignsByLogin_0' => [ + 'application/json', + ], + 'getCampaigns_0' => [ + 'application/json', + ], + 'getCategoriesMaxSaleQuantum_2' => [ + 'application/json', + ], + 'getCategoriesTree_2' => [ + 'application/json', + ], + 'getCategoryContentParameters_0' => [ + 'application/json', + ], + 'getChatHistory_0' => [ + 'application/json', + ], + 'getChats_0' => [ + 'application/json', + ], + 'getDeliveryServices_1' => [ + 'application/json', + ], + 'getFeedIndexLogs_0' => [ + 'application/json', + ], + 'getFeed_0' => [ + 'application/json', + ], + 'getFeedbackAndCommentUpdates_0' => [ + 'application/json', + ], + 'getFeeds_0' => [ + 'application/json', + ], + 'getGoodsFeedbackComments_2' => [ + 'application/json', + ], + 'getGoodsFeedbacks_2' => [ + 'application/json', + ], + 'getGoodsStats_3' => [ + 'application/json', + ], + 'getHiddenOffers_2' => [ + 'application/json', + ], + 'getModelOffers_0' => [ + 'application/json', + ], + 'getModel_0' => [ + 'application/json', + ], + 'getModelsOffers_0' => [ + 'application/json', + ], + 'getModels_0' => [ + 'application/json', + ], + 'getOfferCardsContentStatus_0' => [ + 'application/json', + ], + 'getOfferMappingEntries_3' => [ + 'application/json', + ], + 'getOfferMappings_0' => [ + 'application/json', + ], + 'getOfferRecommendations_0' => [ + 'application/json', + ], + 'getOffers_0' => [ + 'application/json', + ], + 'getOrderBusinessBuyerInfo_2' => [ + 'application/json', + ], + 'getOrderBusinessDocumentsInfo_2' => [ + 'application/json', + ], + 'getOrderBuyerInfo_0' => [ + 'application/json', + ], + 'getOrderLabelsData_1' => [ + 'application/json', + ], + 'getOrder_2' => [ + 'application/json', + ], + 'getOrdersStats_2' => [ + 'application/json', + ], + 'getOrders_1' => [ + 'application/json', + ], + 'getOutletLicenses_0' => [ + 'application/json', + ], + 'getOutlet_0' => [ + 'application/json', + ], + 'getOutlets_0' => [ + 'application/json', + ], + 'getPricesByOfferIds_2' => [ + 'application/json', + ], + 'getPrices_2' => [ + 'application/json', + ], + 'getPromoOffers_2' => [ + 'application/json', + ], + 'getPromos_2' => [ + 'application/json', + ], + 'getQualityRatingDetails_1' => [ + 'application/json', + ], + 'getQualityRatings_2' => [ + 'application/json', + ], + 'getReportInfo_1' => [ + 'application/json', + ], + 'getReturnApplication_1' => [ + 'application/json', + ], + 'getReturnPhoto_1' => [ + 'application/json', + ], + 'getReturn_1' => [ + 'application/json', + ], + 'getReturns_1' => [ + 'application/json', + ], + 'getStocks_2' => [ + 'application/json', + ], + 'getSuggestedOfferMappingEntries_3' => [ + 'application/json', + ], + 'getSuggestedOfferMappings_0' => [ + 'application/json', + ], + 'getSuggestedPrices_3' => [ + 'application/json', + ], + 'getWarehouses_1' => [ + 'application/json', + ], + 'provideOrderDigitalCodes_0' => [ + 'application/json', + ], + 'provideOrderItemIdentifiers_1' => [ + 'application/json', + ], + 'putBidsForBusiness_0' => [ + 'application/json', + ], + 'putBidsForCampaign_0' => [ + 'application/json', + ], + 'refreshFeed_0' => [ + 'application/json', + ], + 'searchModels_0' => [ + 'application/json', + ], + 'searchRegionChildren_2' => [ + 'application/json', + ], + 'searchRegionsById_2' => [ + 'application/json', + ], + 'searchRegionsByName_2' => [ + 'application/json', + ], + 'sendFileToChat_0' => [ + 'multipart/form-data', + ], + 'sendMessageToChat_0' => [ + 'application/json', + ], + 'setFeedParams_0' => [ + 'application/json', + ], + 'setOrderBoxLayout_2' => [ + 'application/json', + ], + 'setOrderDeliveryDate_0' => [ + 'application/json', + ], + 'setOrderDeliveryTrackCode_0' => [ + 'application/json', + ], + 'setOrderShipmentBoxes_1' => [ + 'application/json', + ], + 'setReturnDecision_0' => [ + 'application/json', + ], + 'skipGoodsFeedbacksReaction_2' => [ + 'application/json', + ], + 'submitReturnDecision_0' => [ + 'application/json', + ], + 'updateBusinessPrices_2' => [ + 'application/json', + ], + 'updateCampaignOffers_0' => [ + 'application/json', + ], + 'updateGoodsFeedbackComment_2' => [ + 'application/json', + ], + 'updateOfferContent_0' => [ + 'application/json', + ], + 'updateOfferMappingEntries_3' => [ + 'application/json', + ], + 'updateOfferMappings_0' => [ + 'application/json', + ], + 'updateOrderItems_1' => [ + 'application/json', + ], + 'updateOrderStatus_1' => [ + 'application/json', + ], + 'updateOrderStatuses_1' => [ + 'application/json', + ], + 'updateOrderStorageLimit_0' => [ + 'application/json', + ], + 'updateOutletLicenses_0' => [ + 'application/json', + ], + 'updateOutlet_0' => [ + 'application/json', + ], + 'updatePrices_2' => [ + 'application/json', + ], + 'updatePromoOffers_2' => [ + 'application/json', + ], + 'updateStocks_1' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation acceptOrderCancellation_0 + * + * Отмена заказа покупателем + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function acceptOrderCancellation_0($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation_0'][0]) + { + list($response) = $this->acceptOrderCancellation_0WithHttpInfo($campaign_id, $order_id, $accept_order_cancellation_request, $contentType); + return $response; + } + + /** + * Operation acceptOrderCancellation_0WithHttpInfo + * + * Отмена заказа покупателем + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function acceptOrderCancellation_0WithHttpInfo($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation_0'][0]) + { + $request = $this->acceptOrderCancellation_0Request($campaign_id, $order_id, $accept_order_cancellation_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation acceptOrderCancellation_0Async + * + * Отмена заказа покупателем + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function acceptOrderCancellation_0Async($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation_0'][0]) + { + return $this->acceptOrderCancellation_0AsyncWithHttpInfo($campaign_id, $order_id, $accept_order_cancellation_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation acceptOrderCancellation_0AsyncWithHttpInfo + * + * Отмена заказа покупателем + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function acceptOrderCancellation_0AsyncWithHttpInfo($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->acceptOrderCancellation_0Request($campaign_id, $order_id, $accept_order_cancellation_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'acceptOrderCancellation_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function acceptOrderCancellation_0Request($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling acceptOrderCancellation_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.acceptOrderCancellation_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling acceptOrderCancellation_0' + ); + } + + // verify the required parameter 'accept_order_cancellation_request' is set + if ($accept_order_cancellation_request === null || (is_array($accept_order_cancellation_request) && count($accept_order_cancellation_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $accept_order_cancellation_request when calling acceptOrderCancellation_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/cancellation/accept'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($accept_order_cancellation_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($accept_order_cancellation_request)); + } else { + $httpBody = $accept_order_cancellation_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation addHiddenOffers_2 + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addHiddenOffers_2($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_2'][0]) + { + list($response) = $this->addHiddenOffers_2WithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation addHiddenOffers_2WithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addHiddenOffers_2WithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_2'][0]) + { + $request = $this->addHiddenOffers_2Request($campaign_id, $add_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addHiddenOffers_2Async + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffers_2Async($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_2'][0]) + { + return $this->addHiddenOffers_2AsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addHiddenOffers_2AsyncWithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffers_2AsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->addHiddenOffers_2Request($campaign_id, $add_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addHiddenOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addHiddenOffers_2Request($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling addHiddenOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.addHiddenOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_hidden_offers_request' is set + if ($add_hidden_offers_request === null || (is_array($add_hidden_offers_request) && count($add_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_hidden_offers_request when calling addHiddenOffers_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_hidden_offers_request)); + } else { + $httpBody = $add_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation addOffersToArchive_0 + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addOffersToArchive_0($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_0'][0]) + { + list($response) = $this->addOffersToArchive_0WithHttpInfo($business_id, $add_offers_to_archive_request, $contentType); + return $response; + } + + /** + * Operation addOffersToArchive_0WithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addOffersToArchive_0WithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_0'][0]) + { + $request = $this->addOffersToArchive_0Request($business_id, $add_offers_to_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\AddOffersToArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\AddOffersToArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addOffersToArchive_0Async + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchive_0Async($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_0'][0]) + { + return $this->addOffersToArchive_0AsyncWithHttpInfo($business_id, $add_offers_to_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addOffersToArchive_0AsyncWithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchive_0AsyncWithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + $request = $this->addOffersToArchive_0Request($business_id, $add_offers_to_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addOffersToArchive_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addOffersToArchive_0Request($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling addOffersToArchive_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.addOffersToArchive_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_offers_to_archive_request' is set + if ($add_offers_to_archive_request === null || (is_array($add_offers_to_archive_request) && count($add_offers_to_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_offers_to_archive_request when calling addOffersToArchive_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/archive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_offers_to_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_offers_to_archive_request)); + } else { + $httpBody = $add_offers_to_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation calculateTariffs_2 + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function calculateTariffs_2($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_2'][0]) + { + list($response) = $this->calculateTariffs_2WithHttpInfo($calculate_tariffs_request, $contentType); + return $response; + } + + /** + * Operation calculateTariffs_2WithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function calculateTariffs_2WithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_2'][0]) + { + $request = $this->calculateTariffs_2Request($calculate_tariffs_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CalculateTariffsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CalculateTariffsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation calculateTariffs_2Async + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffs_2Async($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_2'][0]) + { + return $this->calculateTariffs_2AsyncWithHttpInfo($calculate_tariffs_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation calculateTariffs_2AsyncWithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffs_2AsyncWithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + $request = $this->calculateTariffs_2Request($calculate_tariffs_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'calculateTariffs_2' + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function calculateTariffs_2Request($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_2'][0]) + { + + // verify the required parameter 'calculate_tariffs_request' is set + if ($calculate_tariffs_request === null || (is_array($calculate_tariffs_request) && count($calculate_tariffs_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $calculate_tariffs_request when calling calculateTariffs_2' + ); + } + + + $resourcePath = '/tariffs/calculate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($calculate_tariffs_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($calculate_tariffs_request)); + } else { + $httpBody = $calculate_tariffs_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmBusinessPrices_0 + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmBusinessPrices_0($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_0'][0]) + { + list($response) = $this->confirmBusinessPrices_0WithHttpInfo($business_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmBusinessPrices_0WithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmBusinessPrices_0WithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_0'][0]) + { + $request = $this->confirmBusinessPrices_0Request($business_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmBusinessPrices_0Async + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPrices_0Async($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_0'][0]) + { + return $this->confirmBusinessPrices_0AsyncWithHttpInfo($business_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmBusinessPrices_0AsyncWithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPrices_0AsyncWithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmBusinessPrices_0Request($business_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmBusinessPrices_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmBusinessPrices_0Request($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling confirmBusinessPrices_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.confirmBusinessPrices_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmBusinessPrices_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmCampaignPrices_0 + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmCampaignPrices_0($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_0'][0]) + { + list($response) = $this->confirmCampaignPrices_0WithHttpInfo($campaign_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmCampaignPrices_0WithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmCampaignPrices_0WithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_0'][0]) + { + $request = $this->confirmCampaignPrices_0Request($campaign_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmCampaignPrices_0Async + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPrices_0Async($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_0'][0]) + { + return $this->confirmCampaignPrices_0AsyncWithHttpInfo($campaign_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmCampaignPrices_0AsyncWithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPrices_0AsyncWithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmCampaignPrices_0Request($campaign_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmCampaignPrices_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmCampaignPrices_0Request($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling confirmCampaignPrices_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.confirmCampaignPrices_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmCampaignPrices_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation createChat_0 + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function createChat_0($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_0'][0]) + { + list($response) = $this->createChat_0WithHttpInfo($business_id, $create_chat_request, $contentType); + return $response; + } + + /** + * Operation createChat_0WithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function createChat_0WithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_0'][0]) + { + $request = $this->createChat_0Request($business_id, $create_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CreateChatResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CreateChatResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CreateChatResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CreateChatResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createChat_0Async + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChat_0Async($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_0'][0]) + { + return $this->createChat_0AsyncWithHttpInfo($business_id, $create_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createChat_0AsyncWithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChat_0AsyncWithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + $request = $this->createChat_0Request($business_id, $create_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createChat_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createChat_0Request($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling createChat_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.createChat_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'create_chat_request' is set + if ($create_chat_request === null || (is_array($create_chat_request) && count($create_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $create_chat_request when calling createChat_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/new'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($create_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($create_chat_request)); + } else { + $httpBody = $create_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation createOutlet_0 + * + * Создание точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CreateOutletResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function createOutlet_0($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet_0'][0]) + { + list($response) = $this->createOutlet_0WithHttpInfo($campaign_id, $change_outlet_request, $contentType); + return $response; + } + + /** + * Operation createOutlet_0WithHttpInfo + * + * Создание точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CreateOutletResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function createOutlet_0WithHttpInfo($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet_0'][0]) + { + $request = $this->createOutlet_0Request($campaign_id, $change_outlet_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CreateOutletResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CreateOutletResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CreateOutletResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CreateOutletResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CreateOutletResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createOutlet_0Async + * + * Создание точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createOutlet_0Async($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet_0'][0]) + { + return $this->createOutlet_0AsyncWithHttpInfo($campaign_id, $change_outlet_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createOutlet_0AsyncWithHttpInfo + * + * Создание точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createOutlet_0AsyncWithHttpInfo($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\CreateOutletResponse'; + $request = $this->createOutlet_0Request($campaign_id, $change_outlet_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createOutlet_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createOutlet_0Request($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling createOutlet_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.createOutlet_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'change_outlet_request' is set + if ($change_outlet_request === null || (is_array($change_outlet_request) && count($change_outlet_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $change_outlet_request when calling createOutlet_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($change_outlet_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($change_outlet_request)); + } else { + $httpBody = $change_outlet_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteCampaignOffers_0 + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteCampaignOffers_0($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_0'][0]) + { + list($response) = $this->deleteCampaignOffers_0WithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteCampaignOffers_0WithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteCampaignOffers_0WithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_0'][0]) + { + $request = $this->deleteCampaignOffers_0Request($campaign_id, $delete_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteCampaignOffers_0Async + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffers_0Async($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_0'][0]) + { + return $this->deleteCampaignOffers_0AsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteCampaignOffers_0AsyncWithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffers_0AsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + $request = $this->deleteCampaignOffers_0Request($campaign_id, $delete_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteCampaignOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteCampaignOffers_0Request($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteCampaignOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.deleteCampaignOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_campaign_offers_request' is set + if ($delete_campaign_offers_request === null || (is_array($delete_campaign_offers_request) && count($delete_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_campaign_offers_request when calling deleteCampaignOffers_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_campaign_offers_request)); + } else { + $httpBody = $delete_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteGoodsFeedbackComment_2 + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteGoodsFeedbackComment_2($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_2'][0]) + { + list($response) = $this->deleteGoodsFeedbackComment_2WithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation deleteGoodsFeedbackComment_2WithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteGoodsFeedbackComment_2WithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_2'][0]) + { + $request = $this->deleteGoodsFeedbackComment_2Request($business_id, $delete_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteGoodsFeedbackComment_2Async + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackComment_2Async($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_2'][0]) + { + return $this->deleteGoodsFeedbackComment_2AsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteGoodsFeedbackComment_2AsyncWithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackComment_2AsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteGoodsFeedbackComment_2Request($business_id, $delete_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteGoodsFeedbackComment_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteGoodsFeedbackComment_2Request($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteGoodsFeedbackComment_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.deleteGoodsFeedbackComment_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_goods_feedback_comment_request' is set + if ($delete_goods_feedback_comment_request === null || (is_array($delete_goods_feedback_comment_request) && count($delete_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_goods_feedback_comment_request when calling deleteGoodsFeedbackComment_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_goods_feedback_comment_request)); + } else { + $httpBody = $delete_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteHiddenOffers_2 + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteHiddenOffers_2($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_2'][0]) + { + list($response) = $this->deleteHiddenOffers_2WithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteHiddenOffers_2WithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteHiddenOffers_2WithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_2'][0]) + { + $request = $this->deleteHiddenOffers_2Request($campaign_id, $delete_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteHiddenOffers_2Async + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffers_2Async($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_2'][0]) + { + return $this->deleteHiddenOffers_2AsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteHiddenOffers_2AsyncWithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffers_2AsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteHiddenOffers_2Request($campaign_id, $delete_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteHiddenOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteHiddenOffers_2Request($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteHiddenOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.deleteHiddenOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_hidden_offers_request' is set + if ($delete_hidden_offers_request === null || (is_array($delete_hidden_offers_request) && count($delete_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_hidden_offers_request when calling deleteHiddenOffers_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_hidden_offers_request)); + } else { + $httpBody = $delete_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffersFromArchive_0 + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffersFromArchive_0($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_0'][0]) + { + list($response) = $this->deleteOffersFromArchive_0WithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType); + return $response; + } + + /** + * Operation deleteOffersFromArchive_0WithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffersFromArchive_0WithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_0'][0]) + { + $request = $this->deleteOffersFromArchive_0Request($business_id, $delete_offers_from_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffersFromArchive_0Async + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchive_0Async($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_0'][0]) + { + return $this->deleteOffersFromArchive_0AsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffersFromArchive_0AsyncWithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchive_0AsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + $request = $this->deleteOffersFromArchive_0Request($business_id, $delete_offers_from_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffersFromArchive_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffersFromArchive_0Request($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffersFromArchive_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.deleteOffersFromArchive_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_from_archive_request' is set + if ($delete_offers_from_archive_request === null || (is_array($delete_offers_from_archive_request) && count($delete_offers_from_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_from_archive_request when calling deleteOffersFromArchive_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/unarchive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_from_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_from_archive_request)); + } else { + $httpBody = $delete_offers_from_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffers_0 + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffers_0($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_0'][0]) + { + list($response) = $this->deleteOffers_0WithHttpInfo($business_id, $delete_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteOffers_0WithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffers_0WithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_0'][0]) + { + $request = $this->deleteOffers_0Request($business_id, $delete_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffers_0Async + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffers_0Async($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_0'][0]) + { + return $this->deleteOffers_0AsyncWithHttpInfo($business_id, $delete_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffers_0AsyncWithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffers_0AsyncWithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + $request = $this->deleteOffers_0Request($business_id, $delete_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffers_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffers_0Request($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffers_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.deleteOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_request' is set + if ($delete_offers_request === null || (is_array($delete_offers_request) && count($delete_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_request when calling deleteOffers_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_request)); + } else { + $httpBody = $delete_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOutletLicenses_0 + * + * Удаление лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOutletLicenses_0($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses_0'][0]) + { + list($response) = $this->deleteOutletLicenses_0WithHttpInfo($campaign_id, $ids, $contentType); + return $response; + } + + /** + * Operation deleteOutletLicenses_0WithHttpInfo + * + * Удаление лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOutletLicenses_0WithHttpInfo($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses_0'][0]) + { + $request = $this->deleteOutletLicenses_0Request($campaign_id, $ids, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOutletLicenses_0Async + * + * Удаление лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOutletLicenses_0Async($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses_0'][0]) + { + return $this->deleteOutletLicenses_0AsyncWithHttpInfo($campaign_id, $ids, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOutletLicenses_0AsyncWithHttpInfo + * + * Удаление лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOutletLicenses_0AsyncWithHttpInfo($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteOutletLicenses_0Request($campaign_id, $ids, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOutletLicenses_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOutletLicenses_0Request($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteOutletLicenses_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.deleteOutletLicenses_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'ids' is set + if ($ids === null || (is_array($ids) && count($ids) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $ids when calling deleteOutletLicenses_0' + ); + } + if (count($ids) < 1) { + throw new \InvalidArgumentException('invalid value for "$ids" when calling DbsApi.deleteOutletLicenses_0, number of items must be greater than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/licenses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $ids, + 'ids', // param base name + 'array', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOutlet_0 + * + * Удаление точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOutlet_0($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet_0'][0]) + { + list($response) = $this->deleteOutlet_0WithHttpInfo($campaign_id, $outlet_id, $contentType); + return $response; + } + + /** + * Operation deleteOutlet_0WithHttpInfo + * + * Удаление точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOutlet_0WithHttpInfo($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet_0'][0]) + { + $request = $this->deleteOutlet_0Request($campaign_id, $outlet_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOutlet_0Async + * + * Удаление точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOutlet_0Async($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet_0'][0]) + { + return $this->deleteOutlet_0AsyncWithHttpInfo($campaign_id, $outlet_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOutlet_0AsyncWithHttpInfo + * + * Удаление точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOutlet_0AsyncWithHttpInfo($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteOutlet_0Request($campaign_id, $outlet_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOutlet_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOutlet_0Request($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteOutlet_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.deleteOutlet_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'outlet_id' is set + if ($outlet_id === null || (is_array($outlet_id) && count($outlet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $outlet_id when calling deleteOutlet_0' + ); + } + if ($outlet_id < 1) { + throw new \InvalidArgumentException('invalid value for "$outlet_id" when calling DbsApi.deleteOutlet_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/{outletId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($outlet_id !== null) { + $resourcePath = str_replace( + '{' . 'outletId' . '}', + ObjectSerializer::toPathValue($outlet_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deletePromoOffers_2 + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deletePromoOffers_2($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_2'][0]) + { + list($response) = $this->deletePromoOffers_2WithHttpInfo($business_id, $delete_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation deletePromoOffers_2WithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deletePromoOffers_2WithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_2'][0]) + { + $request = $this->deletePromoOffers_2Request($business_id, $delete_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeletePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeletePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deletePromoOffers_2Async + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffers_2Async($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_2'][0]) + { + return $this->deletePromoOffers_2AsyncWithHttpInfo($business_id, $delete_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deletePromoOffers_2AsyncWithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffers_2AsyncWithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + $request = $this->deletePromoOffers_2Request($business_id, $delete_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePromoOffers_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deletePromoOffers_2Request($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deletePromoOffers_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.deletePromoOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_promo_offers_request' is set + if ($delete_promo_offers_request === null || (is_array($delete_promo_offers_request) && count($delete_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_promo_offers_request when calling deletePromoOffers_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_promo_offers_request)); + } else { + $httpBody = $delete_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateBoostConsolidatedReport_2 + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateBoostConsolidatedReport_2($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_2'][0]) + { + list($response) = $this->generateBoostConsolidatedReport_2WithHttpInfo($generate_boost_consolidated_request, $format, $contentType); + return $response; + } + + /** + * Operation generateBoostConsolidatedReport_2WithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateBoostConsolidatedReport_2WithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_2'][0]) + { + $request = $this->generateBoostConsolidatedReport_2Request($generate_boost_consolidated_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateBoostConsolidatedReport_2Async + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReport_2Async($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_2'][0]) + { + return $this->generateBoostConsolidatedReport_2AsyncWithHttpInfo($generate_boost_consolidated_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateBoostConsolidatedReport_2AsyncWithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReport_2AsyncWithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateBoostConsolidatedReport_2Request($generate_boost_consolidated_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateBoostConsolidatedReport_2' + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateBoostConsolidatedReport_2Request($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_2'][0]) + { + + // verify the required parameter 'generate_boost_consolidated_request' is set + if ($generate_boost_consolidated_request === null || (is_array($generate_boost_consolidated_request) && count($generate_boost_consolidated_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_boost_consolidated_request when calling generateBoostConsolidatedReport_2' + ); + } + + + + $resourcePath = '/reports/boost-consolidated/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_boost_consolidated_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_boost_consolidated_request)); + } else { + $httpBody = $generate_boost_consolidated_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateCompetitorsPositionReport_1 + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateCompetitorsPositionReport_1($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_1'][0]) + { + list($response) = $this->generateCompetitorsPositionReport_1WithHttpInfo($generate_competitors_position_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateCompetitorsPositionReport_1WithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateCompetitorsPositionReport_1WithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_1'][0]) + { + $request = $this->generateCompetitorsPositionReport_1Request($generate_competitors_position_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateCompetitorsPositionReport_1Async + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReport_1Async($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_1'][0]) + { + return $this->generateCompetitorsPositionReport_1AsyncWithHttpInfo($generate_competitors_position_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateCompetitorsPositionReport_1AsyncWithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReport_1AsyncWithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateCompetitorsPositionReport_1Request($generate_competitors_position_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateCompetitorsPositionReport_1' + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateCompetitorsPositionReport_1Request($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_1'][0]) + { + + // verify the required parameter 'generate_competitors_position_report_request' is set + if ($generate_competitors_position_report_request === null || (is_array($generate_competitors_position_report_request) && count($generate_competitors_position_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_competitors_position_report_request when calling generateCompetitorsPositionReport_1' + ); + } + + + + $resourcePath = '/reports/competitors-position/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_competitors_position_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_competitors_position_report_request)); + } else { + $httpBody = $generate_competitors_position_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsFeedbackReport_2 + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsFeedbackReport_2($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_2'][0]) + { + list($response) = $this->generateGoodsFeedbackReport_2WithHttpInfo($generate_goods_feedback_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsFeedbackReport_2WithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsFeedbackReport_2WithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_2'][0]) + { + $request = $this->generateGoodsFeedbackReport_2Request($generate_goods_feedback_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsFeedbackReport_2Async + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReport_2Async($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_2'][0]) + { + return $this->generateGoodsFeedbackReport_2AsyncWithHttpInfo($generate_goods_feedback_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsFeedbackReport_2AsyncWithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReport_2AsyncWithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsFeedbackReport_2Request($generate_goods_feedback_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsFeedbackReport_2' + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsFeedbackReport_2Request($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_2'][0]) + { + + // verify the required parameter 'generate_goods_feedback_request' is set + if ($generate_goods_feedback_request === null || (is_array($generate_goods_feedback_request) && count($generate_goods_feedback_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_feedback_request when calling generateGoodsFeedbackReport_2' + ); + } + + + + $resourcePath = '/reports/goods-feedback/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_feedback_request)); + } else { + $httpBody = $generate_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateMassOrderLabelsReport_1 + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateMassOrderLabelsReport_1($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_1'][0]) + { + list($response) = $this->generateMassOrderLabelsReport_1WithHttpInfo($generate_mass_order_labels_request, $format, $contentType); + return $response; + } + + /** + * Operation generateMassOrderLabelsReport_1WithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateMassOrderLabelsReport_1WithHttpInfo($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_1'][0]) + { + $request = $this->generateMassOrderLabelsReport_1Request($generate_mass_order_labels_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateMassOrderLabelsReport_1Async + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateMassOrderLabelsReport_1Async($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_1'][0]) + { + return $this->generateMassOrderLabelsReport_1AsyncWithHttpInfo($generate_mass_order_labels_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateMassOrderLabelsReport_1AsyncWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateMassOrderLabelsReport_1AsyncWithHttpInfo($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateMassOrderLabelsReport_1Request($generate_mass_order_labels_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateMassOrderLabelsReport_1' + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateMassOrderLabelsReport_1Request($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_1'][0]) + { + + // verify the required parameter 'generate_mass_order_labels_request' is set + if ($generate_mass_order_labels_request === null || (is_array($generate_mass_order_labels_request) && count($generate_mass_order_labels_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_mass_order_labels_request when calling generateMassOrderLabelsReport_1' + ); + } + + + + $resourcePath = '/reports/documents/labels/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_mass_order_labels_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_mass_order_labels_request)); + } else { + $httpBody = $generate_mass_order_labels_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateOrderLabel_1 + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateOrderLabel_1($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_1'][0]) + { + list($response) = $this->generateOrderLabel_1WithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + return $response; + } + + /** + * Operation generateOrderLabel_1WithHttpInfo + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateOrderLabel_1WithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_1'][0]) + { + $request = $this->generateOrderLabel_1Request($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateOrderLabel_1Async + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabel_1Async($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_1'][0]) + { + return $this->generateOrderLabel_1AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateOrderLabel_1AsyncWithHttpInfo + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabel_1AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_1'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->generateOrderLabel_1Request($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateOrderLabel_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateOrderLabel_1Request($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling generateOrderLabel_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.generateOrderLabel_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling generateOrderLabel_1' + ); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling generateOrderLabel_1' + ); + } + + // verify the required parameter 'box_id' is set + if ($box_id === null || (is_array($box_id) && count($box_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $box_id when calling generateOrderLabel_1' + ); + } + + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes/{boxId}/label'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + // path params + if ($box_id !== null) { + $resourcePath = str_replace( + '{' . 'boxId' . '}', + ObjectSerializer::toPathValue($box_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateOrderLabels_1 + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateOrderLabels_1($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_1'][0]) + { + list($response) = $this->generateOrderLabels_1WithHttpInfo($campaign_id, $order_id, $format, $contentType); + return $response; + } + + /** + * Operation generateOrderLabels_1WithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateOrderLabels_1WithHttpInfo($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_1'][0]) + { + $request = $this->generateOrderLabels_1Request($campaign_id, $order_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateOrderLabels_1Async + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabels_1Async($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_1'][0]) + { + return $this->generateOrderLabels_1AsyncWithHttpInfo($campaign_id, $order_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateOrderLabels_1AsyncWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabels_1AsyncWithHttpInfo($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_1'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->generateOrderLabels_1Request($campaign_id, $order_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateOrderLabels_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateOrderLabels_1Request($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling generateOrderLabels_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.generateOrderLabels_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling generateOrderLabels_1' + ); + } + + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/labels'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generatePricesReport_2 + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generatePricesReport_2($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_2'][0]) + { + list($response) = $this->generatePricesReport_2WithHttpInfo($generate_prices_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generatePricesReport_2WithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generatePricesReport_2WithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_2'][0]) + { + $request = $this->generatePricesReport_2Request($generate_prices_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generatePricesReport_2Async + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReport_2Async($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_2'][0]) + { + return $this->generatePricesReport_2AsyncWithHttpInfo($generate_prices_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generatePricesReport_2AsyncWithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReport_2AsyncWithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generatePricesReport_2Request($generate_prices_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generatePricesReport_2' + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generatePricesReport_2Request($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_2'][0]) + { + + // verify the required parameter 'generate_prices_report_request' is set + if ($generate_prices_report_request === null || (is_array($generate_prices_report_request) && count($generate_prices_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_prices_report_request when calling generatePricesReport_2' + ); + } + + + + $resourcePath = '/reports/prices/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_prices_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_prices_report_request)); + } else { + $httpBody = $generate_prices_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShelfsStatisticsReport_2 + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShelfsStatisticsReport_2($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_2'][0]) + { + list($response) = $this->generateShelfsStatisticsReport_2WithHttpInfo($generate_shelfs_statistics_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShelfsStatisticsReport_2WithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShelfsStatisticsReport_2WithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_2'][0]) + { + $request = $this->generateShelfsStatisticsReport_2Request($generate_shelfs_statistics_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShelfsStatisticsReport_2Async + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReport_2Async($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_2'][0]) + { + return $this->generateShelfsStatisticsReport_2AsyncWithHttpInfo($generate_shelfs_statistics_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShelfsStatisticsReport_2AsyncWithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReport_2AsyncWithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShelfsStatisticsReport_2Request($generate_shelfs_statistics_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShelfsStatisticsReport_2' + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShelfsStatisticsReport_2Request($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_2'][0]) + { + + // verify the required parameter 'generate_shelfs_statistics_request' is set + if ($generate_shelfs_statistics_request === null || (is_array($generate_shelfs_statistics_request) && count($generate_shelfs_statistics_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shelfs_statistics_request when calling generateShelfsStatisticsReport_2' + ); + } + + + + $resourcePath = '/reports/shelf-statistics/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shelfs_statistics_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shelfs_statistics_request)); + } else { + $httpBody = $generate_shelfs_statistics_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShowsSalesReport_1 + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShowsSalesReport_1($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_1'][0]) + { + list($response) = $this->generateShowsSalesReport_1WithHttpInfo($generate_shows_sales_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShowsSalesReport_1WithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShowsSalesReport_1WithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_1'][0]) + { + $request = $this->generateShowsSalesReport_1Request($generate_shows_sales_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShowsSalesReport_1Async + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReport_1Async($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_1'][0]) + { + return $this->generateShowsSalesReport_1AsyncWithHttpInfo($generate_shows_sales_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShowsSalesReport_1AsyncWithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReport_1AsyncWithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShowsSalesReport_1Request($generate_shows_sales_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShowsSalesReport_1' + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShowsSalesReport_1Request($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_1'][0]) + { + + // verify the required parameter 'generate_shows_sales_report_request' is set + if ($generate_shows_sales_report_request === null || (is_array($generate_shows_sales_report_request) && count($generate_shows_sales_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shows_sales_report_request when calling generateShowsSalesReport_1' + ); + } + + + + $resourcePath = '/reports/shows-sales/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shows_sales_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shows_sales_report_request)); + } else { + $httpBody = $generate_shows_sales_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateStocksOnWarehousesReport_2 + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateStocksOnWarehousesReport_2($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_2'][0]) + { + list($response) = $this->generateStocksOnWarehousesReport_2WithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateStocksOnWarehousesReport_2WithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateStocksOnWarehousesReport_2WithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_2'][0]) + { + $request = $this->generateStocksOnWarehousesReport_2Request($generate_stocks_on_warehouses_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateStocksOnWarehousesReport_2Async + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReport_2Async($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_2'][0]) + { + return $this->generateStocksOnWarehousesReport_2AsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateStocksOnWarehousesReport_2AsyncWithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReport_2AsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateStocksOnWarehousesReport_2Request($generate_stocks_on_warehouses_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateStocksOnWarehousesReport_2' + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateStocksOnWarehousesReport_2Request($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_2'][0]) + { + + // verify the required parameter 'generate_stocks_on_warehouses_report_request' is set + if ($generate_stocks_on_warehouses_report_request === null || (is_array($generate_stocks_on_warehouses_report_request) && count($generate_stocks_on_warehouses_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_stocks_on_warehouses_report_request when calling generateStocksOnWarehousesReport_2' + ); + } + + + + $resourcePath = '/reports/stocks-on-warehouses/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_stocks_on_warehouses_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_stocks_on_warehouses_report_request)); + } else { + $httpBody = $generate_stocks_on_warehouses_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport_1 + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedMarketplaceServicesReport_1($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_1'][0]) + { + list($response) = $this->generateUnitedMarketplaceServicesReport_1WithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedMarketplaceServicesReport_1WithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedMarketplaceServicesReport_1WithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_1'][0]) + { + $request = $this->generateUnitedMarketplaceServicesReport_1Request($generate_united_marketplace_services_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedMarketplaceServicesReport_1Async + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReport_1Async($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_1'][0]) + { + return $this->generateUnitedMarketplaceServicesReport_1AsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport_1AsyncWithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReport_1AsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedMarketplaceServicesReport_1Request($generate_united_marketplace_services_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedMarketplaceServicesReport_1' + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedMarketplaceServicesReport_1Request($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_1'][0]) + { + + // verify the required parameter 'generate_united_marketplace_services_report_request' is set + if ($generate_united_marketplace_services_report_request === null || (is_array($generate_united_marketplace_services_report_request) && count($generate_united_marketplace_services_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_marketplace_services_report_request when calling generateUnitedMarketplaceServicesReport_1' + ); + } + + + + $resourcePath = '/reports/united-marketplace-services/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_marketplace_services_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_marketplace_services_report_request)); + } else { + $httpBody = $generate_united_marketplace_services_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedNettingReport_1 + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedNettingReport_1($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_1'][0]) + { + list($response) = $this->generateUnitedNettingReport_1WithHttpInfo($generate_united_netting_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedNettingReport_1WithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedNettingReport_1WithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_1'][0]) + { + $request = $this->generateUnitedNettingReport_1Request($generate_united_netting_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedNettingReport_1Async + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReport_1Async($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_1'][0]) + { + return $this->generateUnitedNettingReport_1AsyncWithHttpInfo($generate_united_netting_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedNettingReport_1AsyncWithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReport_1AsyncWithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedNettingReport_1Request($generate_united_netting_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedNettingReport_1' + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedNettingReport_1Request($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_1'][0]) + { + + // verify the required parameter 'generate_united_netting_report_request' is set + if ($generate_united_netting_report_request === null || (is_array($generate_united_netting_report_request) && count($generate_united_netting_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_netting_report_request when calling generateUnitedNettingReport_1' + ); + } + + + + $resourcePath = '/reports/united-netting/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_netting_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_netting_report_request)); + } else { + $httpBody = $generate_united_netting_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedOrdersReport_2 + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedOrdersReport_2($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_2'][0]) + { + list($response) = $this->generateUnitedOrdersReport_2WithHttpInfo($generate_united_orders_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedOrdersReport_2WithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedOrdersReport_2WithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_2'][0]) + { + $request = $this->generateUnitedOrdersReport_2Request($generate_united_orders_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedOrdersReport_2Async + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReport_2Async($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_2'][0]) + { + return $this->generateUnitedOrdersReport_2AsyncWithHttpInfo($generate_united_orders_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedOrdersReport_2AsyncWithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReport_2AsyncWithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedOrdersReport_2Request($generate_united_orders_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedOrdersReport_2' + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedOrdersReport_2Request($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_2'][0]) + { + + // verify the required parameter 'generate_united_orders_request' is set + if ($generate_united_orders_request === null || (is_array($generate_united_orders_request) && count($generate_united_orders_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_orders_request when calling generateUnitedOrdersReport_2' + ); + } + + + + $resourcePath = '/reports/united-orders/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_orders_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_orders_request)); + } else { + $httpBody = $generate_united_orders_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getAllOffers_0 + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getAllOffers_0($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_0'][0]) + { + list($response) = $this->getAllOffers_0WithHttpInfo($campaign_id, $feed_id, $chunk, $contentType); + return $response; + } + + /** + * Operation getAllOffers_0WithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getAllOffers_0WithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_0'][0]) + { + $request = $this->getAllOffers_0Request($campaign_id, $feed_id, $chunk, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetAllOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetAllOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetAllOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetAllOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getAllOffers_0Async + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffers_0Async($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_0'][0]) + { + return $this->getAllOffers_0AsyncWithHttpInfo($campaign_id, $feed_id, $chunk, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getAllOffers_0AsyncWithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffers_0AsyncWithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + $request = $this->getAllOffers_0Request($campaign_id, $feed_id, $chunk, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getAllOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getAllOffers_0Request($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getAllOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getAllOffers_0, must be bigger than or equal to 1.'); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers/all'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chunk, + 'chunk', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsInfoForBusiness_0 + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsInfoForBusiness_0($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_0'][0]) + { + list($response) = $this->getBidsInfoForBusiness_0WithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + return $response; + } + + /** + * Operation getBidsInfoForBusiness_0WithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsInfoForBusiness_0WithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_0'][0]) + { + $request = $this->getBidsInfoForBusiness_0Request($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsInfoForBusiness_0Async + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusiness_0Async($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_0'][0]) + { + return $this->getBidsInfoForBusiness_0AsyncWithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsInfoForBusiness_0AsyncWithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusiness_0AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + $request = $this->getBidsInfoForBusiness_0Request($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsInfoForBusiness_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsInfoForBusiness_0Request($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsInfoForBusiness_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getBidsInfoForBusiness_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/bids/info'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_info_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_info_request)); + } else { + $httpBody = $get_bids_info_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsRecommendations_0 + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsRecommendations_0($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_0'][0]) + { + list($response) = $this->getBidsRecommendations_0WithHttpInfo($business_id, $get_bids_recommendations_request, $contentType); + return $response; + } + + /** + * Operation getBidsRecommendations_0WithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsRecommendations_0WithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_0'][0]) + { + $request = $this->getBidsRecommendations_0Request($business_id, $get_bids_recommendations_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsRecommendations_0Async + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendations_0Async($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_0'][0]) + { + return $this->getBidsRecommendations_0AsyncWithHttpInfo($business_id, $get_bids_recommendations_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsRecommendations_0AsyncWithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendations_0AsyncWithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + $request = $this->getBidsRecommendations_0Request($business_id, $get_bids_recommendations_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsRecommendations_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsRecommendations_0Request($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsRecommendations_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getBidsRecommendations_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_bids_recommendations_request' is set + if ($get_bids_recommendations_request === null || (is_array($get_bids_recommendations_request) && count($get_bids_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_bids_recommendations_request when calling getBidsRecommendations_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_recommendations_request)); + } else { + $httpBody = $get_bids_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessQuarantineOffers_0 + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessQuarantineOffers_0($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_0'][0]) + { + list($response) = $this->getBusinessQuarantineOffers_0WithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getBusinessQuarantineOffers_0WithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessQuarantineOffers_0WithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_0'][0]) + { + $request = $this->getBusinessQuarantineOffers_0Request($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessQuarantineOffers_0Async + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffers_0Async($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_0'][0]) + { + return $this->getBusinessQuarantineOffers_0AsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessQuarantineOffers_0AsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffers_0AsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getBusinessQuarantineOffers_0Request($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessQuarantineOffers_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessQuarantineOffers_0Request($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessQuarantineOffers_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getBusinessQuarantineOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getBusinessQuarantineOffers_0' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessSettings_0 + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessSettings_0($business_id, string $contentType = self::contentTypes['getBusinessSettings_0'][0]) + { + list($response) = $this->getBusinessSettings_0WithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getBusinessSettings_0WithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessSettings_0WithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings_0'][0]) + { + $request = $this->getBusinessSettings_0Request($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessSettings_0Async + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettings_0Async($business_id, string $contentType = self::contentTypes['getBusinessSettings_0'][0]) + { + return $this->getBusinessSettings_0AsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessSettings_0AsyncWithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettings_0AsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + $request = $this->getBusinessSettings_0Request($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessSettings_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessSettings_0Request($business_id, string $contentType = self::contentTypes['getBusinessSettings_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessSettings_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getBusinessSettings_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignLogins_0 + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignLogins_0($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_0'][0]) + { + list($response) = $this->getCampaignLogins_0WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignLogins_0WithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignLogins_0WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_0'][0]) + { + $request = $this->getCampaignLogins_0Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignLoginsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignLoginsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignLogins_0Async + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLogins_0Async($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_0'][0]) + { + return $this->getCampaignLogins_0AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignLogins_0AsyncWithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLogins_0AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + $request = $this->getCampaignLogins_0Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignLogins_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignLogins_0Request($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignLogins_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getCampaignLogins_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/logins'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignOffers_0 + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignOffers_0($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_0'][0]) + { + list($response) = $this->getCampaignOffers_0WithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignOffers_0WithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignOffers_0WithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_0'][0]) + { + $request = $this->getCampaignOffers_0Request($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignOffers_0Async + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffers_0Async($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_0'][0]) + { + return $this->getCampaignOffers_0AsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignOffers_0AsyncWithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffers_0AsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + $request = $this->getCampaignOffers_0Request($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignOffers_0Request($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getCampaignOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_campaign_offers_request' is set + if ($get_campaign_offers_request === null || (is_array($get_campaign_offers_request) && count($get_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_campaign_offers_request when calling getCampaignOffers_0' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_campaign_offers_request)); + } else { + $httpBody = $get_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignQuarantineOffers_0 + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignQuarantineOffers_0($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_0'][0]) + { + list($response) = $this->getCampaignQuarantineOffers_0WithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignQuarantineOffers_0WithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignQuarantineOffers_0WithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_0'][0]) + { + $request = $this->getCampaignQuarantineOffers_0Request($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignQuarantineOffers_0Async + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffers_0Async($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_0'][0]) + { + return $this->getCampaignQuarantineOffers_0AsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignQuarantineOffers_0AsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffers_0AsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getCampaignQuarantineOffers_0Request($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignQuarantineOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignQuarantineOffers_0Request($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignQuarantineOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getCampaignQuarantineOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getCampaignQuarantineOffers_0' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignRegion_0 + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getCampaignRegion_0($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_0'][0]) + { + list($response) = $this->getCampaignRegion_0WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignRegion_0WithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getCampaignRegion_0WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_0'][0]) + { + $request = $this->getCampaignRegion_0Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignRegionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignRegionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignRegion_0Async + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegion_0Async($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_0'][0]) + { + return $this->getCampaignRegion_0AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignRegion_0AsyncWithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegion_0AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + $request = $this->getCampaignRegion_0Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignRegion_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getCampaignRegion_0Request($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignRegion_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getCampaignRegion_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/region'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignSettings_0 + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignSettings_0($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_0'][0]) + { + list($response) = $this->getCampaignSettings_0WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignSettings_0WithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignSettings_0WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_0'][0]) + { + $request = $this->getCampaignSettings_0Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignSettings_0Async + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettings_0Async($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_0'][0]) + { + return $this->getCampaignSettings_0AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignSettings_0AsyncWithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettings_0AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + $request = $this->getCampaignSettings_0Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignSettings_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignSettings_0Request($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignSettings_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getCampaignSettings_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaign_0 + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaign_0($campaign_id, string $contentType = self::contentTypes['getCampaign_0'][0]) + { + list($response) = $this->getCampaign_0WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaign_0WithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaign_0WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign_0'][0]) + { + $request = $this->getCampaign_0Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaign_0Async + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaign_0Async($campaign_id, string $contentType = self::contentTypes['getCampaign_0'][0]) + { + return $this->getCampaign_0AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaign_0AsyncWithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaign_0AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + $request = $this->getCampaign_0Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaign_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaign_0Request($campaign_id, string $contentType = self::contentTypes['getCampaign_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaign_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getCampaign_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignsByLogin_0 + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignsByLogin_0($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_0'][0]) + { + list($response) = $this->getCampaignsByLogin_0WithHttpInfo($login, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaignsByLogin_0WithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignsByLogin_0WithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_0'][0]) + { + $request = $this->getCampaignsByLogin_0Request($login, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignsByLogin_0Async + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLogin_0Async($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_0'][0]) + { + return $this->getCampaignsByLogin_0AsyncWithHttpInfo($login, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignsByLogin_0AsyncWithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLogin_0AsyncWithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaignsByLogin_0Request($login, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignsByLogin_0' + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignsByLogin_0Request($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_0'][0]) + { + + // verify the required parameter 'login' is set + if ($login === null || (is_array($login) && count($login) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $login when calling getCampaignsByLogin_0' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling DbsApi.getCampaignsByLogin_0, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/by_login/{login}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($login !== null) { + $resourcePath = str_replace( + '{' . 'login' . '}', + ObjectSerializer::toPathValue($login), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaigns_0 + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaigns_0($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_0'][0]) + { + list($response) = $this->getCampaigns_0WithHttpInfo($page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaigns_0WithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaigns_0WithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_0'][0]) + { + $request = $this->getCampaigns_0Request($page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaigns_0Async + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaigns_0Async($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_0'][0]) + { + return $this->getCampaigns_0AsyncWithHttpInfo($page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaigns_0AsyncWithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaigns_0AsyncWithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaigns_0Request($page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaigns_0' + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaigns_0Request($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_0'][0]) + { + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling DbsApi.getCampaigns_0, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesMaxSaleQuantum_2 + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesMaxSaleQuantum_2($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_2'][0]) + { + list($response) = $this->getCategoriesMaxSaleQuantum_2WithHttpInfo($get_categories_max_sale_quantum_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesMaxSaleQuantum_2WithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesMaxSaleQuantum_2WithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_2'][0]) + { + $request = $this->getCategoriesMaxSaleQuantum_2Request($get_categories_max_sale_quantum_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesMaxSaleQuantum_2Async + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantum_2Async($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_2'][0]) + { + return $this->getCategoriesMaxSaleQuantum_2AsyncWithHttpInfo($get_categories_max_sale_quantum_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesMaxSaleQuantum_2AsyncWithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantum_2AsyncWithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + $request = $this->getCategoriesMaxSaleQuantum_2Request($get_categories_max_sale_quantum_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesMaxSaleQuantum_2' + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesMaxSaleQuantum_2Request($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_2'][0]) + { + + // verify the required parameter 'get_categories_max_sale_quantum_request' is set + if ($get_categories_max_sale_quantum_request === null || (is_array($get_categories_max_sale_quantum_request) && count($get_categories_max_sale_quantum_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_categories_max_sale_quantum_request when calling getCategoriesMaxSaleQuantum_2' + ); + } + + + $resourcePath = '/categories/max-sale-quantum'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_max_sale_quantum_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_max_sale_quantum_request)); + } else { + $httpBody = $get_categories_max_sale_quantum_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesTree_2 + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesTree_2($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_2'][0]) + { + list($response) = $this->getCategoriesTree_2WithHttpInfo($get_categories_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesTree_2WithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesTree_2WithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_2'][0]) + { + $request = $this->getCategoriesTree_2Request($get_categories_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesTree_2Async + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTree_2Async($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_2'][0]) + { + return $this->getCategoriesTree_2AsyncWithHttpInfo($get_categories_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesTree_2AsyncWithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTree_2AsyncWithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + $request = $this->getCategoriesTree_2Request($get_categories_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesTree_2' + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesTree_2Request($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_2'][0]) + { + + + + $resourcePath = '/categories/tree'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_request)); + } else { + $httpBody = $get_categories_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoryContentParameters_0 + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoryContentParameters_0($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_0'][0]) + { + list($response) = $this->getCategoryContentParameters_0WithHttpInfo($category_id, $contentType); + return $response; + } + + /** + * Operation getCategoryContentParameters_0WithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoryContentParameters_0WithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_0'][0]) + { + $request = $this->getCategoryContentParameters_0Request($category_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoryContentParameters_0Async + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParameters_0Async($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_0'][0]) + { + return $this->getCategoryContentParameters_0AsyncWithHttpInfo($category_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoryContentParameters_0AsyncWithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParameters_0AsyncWithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + $request = $this->getCategoryContentParameters_0Request($category_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoryContentParameters_0' + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoryContentParameters_0Request($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_0'][0]) + { + + // verify the required parameter 'category_id' is set + if ($category_id === null || (is_array($category_id) && count($category_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $category_id when calling getCategoryContentParameters_0' + ); + } + if ($category_id < 1) { + throw new \InvalidArgumentException('invalid value for "$category_id" when calling DbsApi.getCategoryContentParameters_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/category/{categoryId}/parameters'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($category_id !== null) { + $resourcePath = str_replace( + '{' . 'categoryId' . '}', + ObjectSerializer::toPathValue($category_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChatHistory_0 + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChatHistory_0($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_0'][0]) + { + list($response) = $this->getChatHistory_0WithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChatHistory_0WithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChatHistory_0WithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_0'][0]) + { + $request = $this->getChatHistory_0Request($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatHistoryResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatHistoryResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChatHistory_0Async + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistory_0Async($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_0'][0]) + { + return $this->getChatHistory_0AsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChatHistory_0AsyncWithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistory_0AsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + $request = $this->getChatHistory_0Request($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChatHistory_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChatHistory_0Request($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChatHistory_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getChatHistory_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling getChatHistory_0' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling DbsApi.getChatHistory_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chat_history_request' is set + if ($get_chat_history_request === null || (is_array($get_chat_history_request) && count($get_chat_history_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chat_history_request when calling getChatHistory_0' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chat_history_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chat_history_request)); + } else { + $httpBody = $get_chat_history_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChats_0 + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChats_0($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_0'][0]) + { + list($response) = $this->getChats_0WithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChats_0WithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChats_0WithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_0'][0]) + { + $request = $this->getChats_0Request($business_id, $get_chats_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChats_0Async + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChats_0Async($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_0'][0]) + { + return $this->getChats_0AsyncWithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChats_0AsyncWithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChats_0AsyncWithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + $request = $this->getChats_0Request($business_id, $get_chats_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChats_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChats_0Request($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChats_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getChats_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chats_request' is set + if ($get_chats_request === null || (is_array($get_chats_request) && count($get_chats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chats_request when calling getChats_0' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chats_request)); + } else { + $httpBody = $get_chats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getDeliveryServices_1 + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetDeliveryServicesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getDeliveryServices_1(string $contentType = self::contentTypes['getDeliveryServices_1'][0]) + { + list($response) = $this->getDeliveryServices_1WithHttpInfo($contentType); + return $response; + } + + /** + * Operation getDeliveryServices_1WithHttpInfo + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetDeliveryServicesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getDeliveryServices_1WithHttpInfo(string $contentType = self::contentTypes['getDeliveryServices_1'][0]) + { + $request = $this->getDeliveryServices_1Request($contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetDeliveryServicesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetDeliveryServicesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetDeliveryServicesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetDeliveryServicesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetDeliveryServicesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getDeliveryServices_1Async + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDeliveryServices_1Async(string $contentType = self::contentTypes['getDeliveryServices_1'][0]) + { + return $this->getDeliveryServices_1AsyncWithHttpInfo($contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getDeliveryServices_1AsyncWithHttpInfo + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDeliveryServices_1AsyncWithHttpInfo(string $contentType = self::contentTypes['getDeliveryServices_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetDeliveryServicesResponse'; + $request = $this->getDeliveryServices_1Request($contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getDeliveryServices_1' + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getDeliveryServices_1Request(string $contentType = self::contentTypes['getDeliveryServices_1'][0]) + { + + + $resourcePath = '/delivery/services'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedIndexLogs_0 + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedIndexLogs_0($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_0'][0]) + { + list($response) = $this->getFeedIndexLogs_0WithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + return $response; + } + + /** + * Operation getFeedIndexLogs_0WithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedIndexLogs_0WithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_0'][0]) + { + $request = $this->getFeedIndexLogs_0Request($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedIndexLogs_0Async + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogs_0Async($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_0'][0]) + { + return $this->getFeedIndexLogs_0AsyncWithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedIndexLogs_0AsyncWithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogs_0AsyncWithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + $request = $this->getFeedIndexLogs_0Request($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedIndexLogs_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedIndexLogs_0Request($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedIndexLogs_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getFeedIndexLogs_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeedIndexLogs_0' + ); + } + + + + + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/index-logs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_from, + 'published_time_from', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_to, + 'published_time_to', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'FeedIndexLogsStatusType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeed_0 + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeed_0($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_0'][0]) + { + list($response) = $this->getFeed_0WithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation getFeed_0WithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeed_0WithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_0'][0]) + { + $request = $this->getFeed_0Request($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeed_0Async + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeed_0Async($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_0'][0]) + { + return $this->getFeed_0AsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeed_0AsyncWithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeed_0AsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + $request = $this->getFeed_0Request($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeed_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeed_0Request($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeed_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getFeed_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeed_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedbackAndCommentUpdates_0 + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedbackAndCommentUpdates_0($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_0'][0]) + { + list($response) = $this->getFeedbackAndCommentUpdates_0WithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType); + return $response; + } + + /** + * Operation getFeedbackAndCommentUpdates_0WithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedbackAndCommentUpdates_0WithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_0'][0]) + { + $request = $this->getFeedbackAndCommentUpdates_0Request($campaign_id, $page_token, $limit, $from_date, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedbackListResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedbackListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedbackAndCommentUpdates_0Async + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdates_0Async($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_0'][0]) + { + return $this->getFeedbackAndCommentUpdates_0AsyncWithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedbackAndCommentUpdates_0AsyncWithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdates_0AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + $request = $this->getFeedbackAndCommentUpdates_0Request($campaign_id, $page_token, $limit, $from_date, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedbackAndCommentUpdates_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedbackAndCommentUpdates_0Request($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedbackAndCommentUpdates_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getFeedbackAndCommentUpdates_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/feedback/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeeds_0 + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeeds_0($campaign_id, string $contentType = self::contentTypes['getFeeds_0'][0]) + { + list($response) = $this->getFeeds_0WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getFeeds_0WithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeeds_0WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds_0'][0]) + { + $request = $this->getFeeds_0Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeeds_0Async + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeeds_0Async($campaign_id, string $contentType = self::contentTypes['getFeeds_0'][0]) + { + return $this->getFeeds_0AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeeds_0AsyncWithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeeds_0AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + $request = $this->getFeeds_0Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeeds_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeeds_0Request($campaign_id, string $contentType = self::contentTypes['getFeeds_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeeds_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getFeeds_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbackComments_2 + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbackComments_2($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_2'][0]) + { + list($response) = $this->getGoodsFeedbackComments_2WithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbackComments_2WithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbackComments_2WithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_2'][0]) + { + $request = $this->getGoodsFeedbackComments_2Request($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbackComments_2Async + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackComments_2Async($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_2'][0]) + { + return $this->getGoodsFeedbackComments_2AsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbackComments_2AsyncWithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackComments_2AsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + $request = $this->getGoodsFeedbackComments_2Request($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbackComments_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbackComments_2Request($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbackComments_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getGoodsFeedbackComments_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_feedback_comments_request' is set + if ($get_goods_feedback_comments_request === null || (is_array($get_goods_feedback_comments_request) && count($get_goods_feedback_comments_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_feedback_comments_request when calling getGoodsFeedbackComments_2' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_comments_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_comments_request)); + } else { + $httpBody = $get_goods_feedback_comments_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbacks_2 + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbacks_2($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_2'][0]) + { + list($response) = $this->getGoodsFeedbacks_2WithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbacks_2WithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbacks_2WithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_2'][0]) + { + $request = $this->getGoodsFeedbacks_2Request($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbacks_2Async + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacks_2Async($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_2'][0]) + { + return $this->getGoodsFeedbacks_2AsyncWithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbacks_2AsyncWithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacks_2AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + $request = $this->getGoodsFeedbacks_2Request($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbacks_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbacks_2Request($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbacks_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getGoodsFeedbacks_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_request)); + } else { + $httpBody = $get_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsStats_3 + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsStats_3($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_3'][0]) + { + list($response) = $this->getGoodsStats_3WithHttpInfo($campaign_id, $get_goods_stats_request, $contentType); + return $response; + } + + /** + * Operation getGoodsStats_3WithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsStats_3WithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_3'][0]) + { + $request = $this->getGoodsStats_3Request($campaign_id, $get_goods_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsStats_3Async + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStats_3Async($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_3'][0]) + { + return $this->getGoodsStats_3AsyncWithHttpInfo($campaign_id, $get_goods_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsStats_3AsyncWithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStats_3AsyncWithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + $request = $this->getGoodsStats_3Request($campaign_id, $get_goods_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsStats_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsStats_3Request($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getGoodsStats_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getGoodsStats_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_stats_request' is set + if ($get_goods_stats_request === null || (is_array($get_goods_stats_request) && count($get_goods_stats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_stats_request when calling getGoodsStats_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/stats/skus'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_stats_request)); + } else { + $httpBody = $get_goods_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getHiddenOffers_2 + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getHiddenOffers_2($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_2'][0]) + { + list($response) = $this->getHiddenOffers_2WithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getHiddenOffers_2WithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getHiddenOffers_2WithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_2'][0]) + { + $request = $this->getHiddenOffers_2Request($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetHiddenOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetHiddenOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getHiddenOffers_2Async + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffers_2Async($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_2'][0]) + { + return $this->getHiddenOffers_2AsyncWithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getHiddenOffers_2AsyncWithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffers_2AsyncWithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + $request = $this->getHiddenOffers_2Request($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getHiddenOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getHiddenOffers_2Request($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getHiddenOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getHiddenOffers_2, must be bigger than or equal to 1.'); + } + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling DbsApi.getHiddenOffers_2, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offset, + 'offset', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getModelOffers_0 + * + * Список предложений для одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetModelsOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getModelOffers_0($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers_0'][0]) + { + list($response) = $this->getModelOffers_0WithHttpInfo($model_id, $region_id, $currency, $order_by_price, $count, $page, $contentType); + return $response; + } + + /** + * Operation getModelOffers_0WithHttpInfo + * + * Список предложений для одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetModelsOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getModelOffers_0WithHttpInfo($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers_0'][0]) + { + $request = $this->getModelOffers_0Request($model_id, $region_id, $currency, $order_by_price, $count, $page, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetModelsOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetModelsOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetModelsOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetModelsOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetModelsOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getModelOffers_0Async + * + * Список предложений для одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelOffers_0Async($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers_0'][0]) + { + return $this->getModelOffers_0AsyncWithHttpInfo($model_id, $region_id, $currency, $order_by_price, $count, $page, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getModelOffers_0AsyncWithHttpInfo + * + * Список предложений для одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelOffers_0AsyncWithHttpInfo($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetModelsOffersResponse'; + $request = $this->getModelOffers_0Request($model_id, $region_id, $currency, $order_by_price, $count, $page, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getModelOffers_0' + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getModelOffers_0Request($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers_0'][0]) + { + + // verify the required parameter 'model_id' is set + if ($model_id === null || (is_array($model_id) && count($model_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $model_id when calling getModelOffers_0' + ); + } + if ($model_id <= 0) { + throw new \InvalidArgumentException('invalid value for "$model_id" when calling DbsApi.getModelOffers_0, must be bigger than 0.'); + } + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling getModelOffers_0' + ); + } + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling DbsApi.getModelOffers_0, must be smaller than or equal to 10000.'); + } + + + $resourcePath = '/models/{modelId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_by_price, + 'orderByPrice', // param base name + 'SortOrderType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $count, + 'count', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($model_id !== null) { + $resourcePath = str_replace( + '{' . 'modelId' . '}', + ObjectSerializer::toPathValue($model_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getModel_0 + * + * Информация об одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getModel_0($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel_0'][0]) + { + list($response) = $this->getModel_0WithHttpInfo($model_id, $region_id, $currency, $contentType); + return $response; + } + + /** + * Operation getModel_0WithHttpInfo + * + * Информация об одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getModel_0WithHttpInfo($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel_0'][0]) + { + $request = $this->getModel_0Request($model_id, $region_id, $currency, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetModelsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetModelsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetModelsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetModelsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetModelsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getModel_0Async + * + * Информация об одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModel_0Async($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel_0'][0]) + { + return $this->getModel_0AsyncWithHttpInfo($model_id, $region_id, $currency, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getModel_0AsyncWithHttpInfo + * + * Информация об одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModel_0AsyncWithHttpInfo($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetModelsResponse'; + $request = $this->getModel_0Request($model_id, $region_id, $currency, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getModel_0' + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getModel_0Request($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel_0'][0]) + { + + // verify the required parameter 'model_id' is set + if ($model_id === null || (is_array($model_id) && count($model_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $model_id when calling getModel_0' + ); + } + if ($model_id <= 0) { + throw new \InvalidArgumentException('invalid value for "$model_id" when calling DbsApi.getModel_0, must be bigger than 0.'); + } + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling getModel_0' + ); + } + + + + $resourcePath = '/models/{modelId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($model_id !== null) { + $resourcePath = str_replace( + '{' . 'modelId' . '}', + ObjectSerializer::toPathValue($model_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getModelsOffers_0 + * + * Список предложений для нескольких моделей + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetModelsOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getModelsOffers_0($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers_0'][0]) + { + list($response) = $this->getModelsOffers_0WithHttpInfo($region_id, $get_models_request, $currency, $order_by_price, $contentType); + return $response; + } + + /** + * Operation getModelsOffers_0WithHttpInfo + * + * Список предложений для нескольких моделей + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetModelsOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getModelsOffers_0WithHttpInfo($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers_0'][0]) + { + $request = $this->getModelsOffers_0Request($region_id, $get_models_request, $currency, $order_by_price, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetModelsOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetModelsOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetModelsOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetModelsOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetModelsOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getModelsOffers_0Async + * + * Список предложений для нескольких моделей + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelsOffers_0Async($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers_0'][0]) + { + return $this->getModelsOffers_0AsyncWithHttpInfo($region_id, $get_models_request, $currency, $order_by_price, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getModelsOffers_0AsyncWithHttpInfo + * + * Список предложений для нескольких моделей + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelsOffers_0AsyncWithHttpInfo($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetModelsOffersResponse'; + $request = $this->getModelsOffers_0Request($region_id, $get_models_request, $currency, $order_by_price, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getModelsOffers_0' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getModelsOffers_0Request($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers_0'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling getModelsOffers_0' + ); + } + + // verify the required parameter 'get_models_request' is set + if ($get_models_request === null || (is_array($get_models_request) && count($get_models_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_models_request when calling getModelsOffers_0' + ); + } + + + + + $resourcePath = '/models/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_by_price, + 'orderByPrice', // param base name + 'SortOrderType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_models_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_models_request)); + } else { + $httpBody = $get_models_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getModels_0 + * + * Информация о нескольких моделях + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getModels_0($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels_0'][0]) + { + list($response) = $this->getModels_0WithHttpInfo($region_id, $get_models_request, $currency, $contentType); + return $response; + } + + /** + * Operation getModels_0WithHttpInfo + * + * Информация о нескольких моделях + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getModels_0WithHttpInfo($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels_0'][0]) + { + $request = $this->getModels_0Request($region_id, $get_models_request, $currency, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetModelsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetModelsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetModelsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetModelsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetModelsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getModels_0Async + * + * Информация о нескольких моделях + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModels_0Async($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels_0'][0]) + { + return $this->getModels_0AsyncWithHttpInfo($region_id, $get_models_request, $currency, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getModels_0AsyncWithHttpInfo + * + * Информация о нескольких моделях + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModels_0AsyncWithHttpInfo($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetModelsResponse'; + $request = $this->getModels_0Request($region_id, $get_models_request, $currency, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getModels_0' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getModels_0Request($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels_0'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling getModels_0' + ); + } + + // verify the required parameter 'get_models_request' is set + if ($get_models_request === null || (is_array($get_models_request) && count($get_models_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_models_request when calling getModels_0' + ); + } + + + + $resourcePath = '/models'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_models_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_models_request)); + } else { + $httpBody = $get_models_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferCardsContentStatus_0 + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferCardsContentStatus_0($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_0'][0]) + { + list($response) = $this->getOfferCardsContentStatus_0WithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + return $response; + } + + /** + * Operation getOfferCardsContentStatus_0WithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferCardsContentStatus_0WithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_0'][0]) + { + $request = $this->getOfferCardsContentStatus_0Request($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferCardsContentStatus_0Async + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatus_0Async($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_0'][0]) + { + return $this->getOfferCardsContentStatus_0AsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferCardsContentStatus_0AsyncWithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatus_0AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + $request = $this->getOfferCardsContentStatus_0Request($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferCardsContentStatus_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferCardsContentStatus_0Request($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferCardsContentStatus_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getOfferCardsContentStatus_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-cards'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_cards_content_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_cards_content_status_request)); + } else { + $httpBody = $get_offer_cards_content_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappingEntries_3 + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOfferMappingEntries_3($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_3'][0]) + { + list($response) = $this->getOfferMappingEntries_3WithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferMappingEntries_3WithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOfferMappingEntries_3WithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_3'][0]) + { + $request = $this->getOfferMappingEntries_3Request($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappingEntries_3Async + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntries_3Async($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_3'][0]) + { + return $this->getOfferMappingEntries_3AsyncWithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappingEntries_3AsyncWithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntries_3AsyncWithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + $request = $this->getOfferMappingEntries_3Request($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappingEntries_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOfferMappingEntries_3Request($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOfferMappingEntries_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOfferMappingEntries_3, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_sku, + 'shop_sku', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $mapping_kind, + 'mapping_kind', // param base name + 'OfferMappingKindType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $availability, + 'availability', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $category_id, + 'category_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $vendor, + 'vendor', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappings_0 + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferMappings_0($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_0'][0]) + { + list($response) = $this->getOfferMappings_0WithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getOfferMappings_0WithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferMappings_0WithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_0'][0]) + { + $request = $this->getOfferMappings_0Request($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappings_0Async + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappings_0Async($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_0'][0]) + { + return $this->getOfferMappings_0AsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappings_0AsyncWithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappings_0AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + $request = $this->getOfferMappings_0Request($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappings_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferMappings_0Request($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferMappings_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getOfferMappings_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-mappings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_mappings_request)); + } else { + $httpBody = $get_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferRecommendations_0 + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferRecommendations_0($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_0'][0]) + { + list($response) = $this->getOfferRecommendations_0WithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferRecommendations_0WithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferRecommendations_0WithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_0'][0]) + { + $request = $this->getOfferRecommendations_0Request($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferRecommendations_0Async + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendations_0Async($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_0'][0]) + { + return $this->getOfferRecommendations_0AsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferRecommendations_0AsyncWithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendations_0AsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + $request = $this->getOfferRecommendations_0Request($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferRecommendations_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferRecommendations_0Request($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferRecommendations_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getOfferRecommendations_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_offer_recommendations_request' is set + if ($get_offer_recommendations_request === null || (is_array($get_offer_recommendations_request) && count($get_offer_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_offer_recommendations_request when calling getOfferRecommendations_0' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/offers/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_recommendations_request)); + } else { + $httpBody = $get_offer_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOffers_0 + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOffers_0($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_0'][0]) + { + list($response) = $this->getOffers_0WithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getOffers_0WithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOffers_0WithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_0'][0]) + { + $request = $this->getOffers_0Request($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOffers_0Async + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffers_0Async($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_0'][0]) + { + return $this->getOffers_0AsyncWithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOffers_0AsyncWithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffers_0AsyncWithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + $request = $this->getOffers_0Request($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOffers_0Request($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOffers_0, must be bigger than or equal to 1.'); + } + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling DbsApi.getOffers_0, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_category_id, + 'shopCategoryId', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $matched, + 'matched', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessBuyerInfo_2 + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessBuyerInfo_2($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_2'][0]) + { + list($response) = $this->getOrderBusinessBuyerInfo_2WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessBuyerInfo_2WithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessBuyerInfo_2WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_2'][0]) + { + $request = $this->getOrderBusinessBuyerInfo_2Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessBuyerInfo_2Async + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfo_2Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_2'][0]) + { + return $this->getOrderBusinessBuyerInfo_2AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessBuyerInfo_2AsyncWithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfo_2AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + $request = $this->getOrderBusinessBuyerInfo_2Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessBuyerInfo_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessBuyerInfo_2Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessBuyerInfo_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOrderBusinessBuyerInfo_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessBuyerInfo_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/business-buyer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo_2 + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessDocumentsInfo_2($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_2'][0]) + { + list($response) = $this->getOrderBusinessDocumentsInfo_2WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessDocumentsInfo_2WithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessDocumentsInfo_2WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_2'][0]) + { + $request = $this->getOrderBusinessDocumentsInfo_2Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessDocumentsInfo_2Async + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfo_2Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_2'][0]) + { + return $this->getOrderBusinessDocumentsInfo_2AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo_2AsyncWithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfo_2AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + $request = $this->getOrderBusinessDocumentsInfo_2Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessDocumentsInfo_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessDocumentsInfo_2Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessDocumentsInfo_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOrderBusinessDocumentsInfo_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessDocumentsInfo_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/documents'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBuyerInfo_0 + * + * Информация о покупателе — физическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBuyerInfo_0($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo_0'][0]) + { + list($response) = $this->getOrderBuyerInfo_0WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBuyerInfo_0WithHttpInfo + * + * Информация о покупателе — физическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBuyerInfo_0WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo_0'][0]) + { + $request = $this->getOrderBuyerInfo_0Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderBuyerInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderBuyerInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderBuyerInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderBuyerInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderBuyerInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBuyerInfo_0Async + * + * Информация о покупателе — физическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBuyerInfo_0Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo_0'][0]) + { + return $this->getOrderBuyerInfo_0AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBuyerInfo_0AsyncWithHttpInfo + * + * Информация о покупателе — физическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBuyerInfo_0AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderBuyerInfoResponse'; + $request = $this->getOrderBuyerInfo_0Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBuyerInfo_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBuyerInfo_0Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBuyerInfo_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOrderBuyerInfo_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBuyerInfo_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/buyer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderLabelsData_1 + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderLabelsDataResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderLabelsData_1($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_1'][0]) + { + list($response) = $this->getOrderLabelsData_1WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderLabelsData_1WithHttpInfo + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderLabelsDataResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderLabelsData_1WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_1'][0]) + { + $request = $this->getOrderLabelsData_1Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderLabelsDataResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderLabelsDataResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderLabelsDataResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderLabelsDataResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderLabelsDataResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderLabelsData_1Async + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderLabelsData_1Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_1'][0]) + { + return $this->getOrderLabelsData_1AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderLabelsData_1AsyncWithHttpInfo + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderLabelsData_1AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderLabelsDataResponse'; + $request = $this->getOrderLabelsData_1Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderLabelsData_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderLabelsData_1Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderLabelsData_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOrderLabelsData_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderLabelsData_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/labels/data'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrder_2 + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrder_2($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_2'][0]) + { + list($response) = $this->getOrder_2WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrder_2WithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrder_2WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_2'][0]) + { + $request = $this->getOrder_2Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrder_2Async + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrder_2Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_2'][0]) + { + return $this->getOrder_2AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrder_2AsyncWithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrder_2AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + $request = $this->getOrder_2Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrder_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrder_2Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrder_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOrder_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrder_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrdersStats_2 + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrdersStats_2($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_2'][0]) + { + list($response) = $this->getOrdersStats_2WithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + return $response; + } + + /** + * Operation getOrdersStats_2WithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrdersStats_2WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_2'][0]) + { + $request = $this->getOrdersStats_2Request($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrdersStats_2Async + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStats_2Async($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_2'][0]) + { + return $this->getOrdersStats_2AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrdersStats_2AsyncWithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStats_2AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + $request = $this->getOrdersStats_2Request($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrdersStats_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrdersStats_2Request($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrdersStats_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOrdersStats_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/stats/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_orders_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_orders_stats_request)); + } else { + $httpBody = $get_orders_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrders_1 + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrders_1($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_1'][0]) + { + list($response) = $this->getOrders_1WithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOrders_1WithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrders_1WithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_1'][0]) + { + $request = $this->getOrders_1Request($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrders_1Async + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrders_1Async($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_1'][0]) + { + return $this->getOrders_1AsyncWithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrders_1AsyncWithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrders_1AsyncWithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + $request = $this->getOrders_1Request($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrders_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrders_1Request($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrders_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOrders_1, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling DbsApi.getOrders_1, must be smaller than or equal to 10000.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $substatus, + 'substatus', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_from, + 'supplierShipmentDateFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_to, + 'supplierShipmentDateTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_from, + 'updatedAtFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_to, + 'updatedAtTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $dispatch_type, + 'dispatchType', // param base name + 'OrderDeliveryDispatchType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $fake, + 'fake', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $has_cis, + 'hasCis', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_waiting_for_cancellation_approve, + 'onlyWaitingForCancellationApprove', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_estimated_delivery, + 'onlyEstimatedDelivery', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_type, + 'buyerType', // param base name + 'OrderBuyerType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOutletLicenses_0 + * + * Информация о лицензиях для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOutletLicensesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOutletLicenses_0($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses_0'][0]) + { + list($response) = $this->getOutletLicenses_0WithHttpInfo($campaign_id, $outlet_ids, $ids, $contentType); + return $response; + } + + /** + * Operation getOutletLicenses_0WithHttpInfo + * + * Информация о лицензиях для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOutletLicensesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOutletLicenses_0WithHttpInfo($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses_0'][0]) + { + $request = $this->getOutletLicenses_0Request($campaign_id, $outlet_ids, $ids, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOutletLicensesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOutletLicensesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOutletLicensesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOutletLicensesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOutletLicensesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOutletLicenses_0Async + * + * Информация о лицензиях для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutletLicenses_0Async($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses_0'][0]) + { + return $this->getOutletLicenses_0AsyncWithHttpInfo($campaign_id, $outlet_ids, $ids, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOutletLicenses_0AsyncWithHttpInfo + * + * Информация о лицензиях для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutletLicenses_0AsyncWithHttpInfo($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOutletLicensesResponse'; + $request = $this->getOutletLicenses_0Request($campaign_id, $outlet_ids, $ids, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOutletLicenses_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOutletLicenses_0Request($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOutletLicenses_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOutletLicenses_0, must be bigger than or equal to 1.'); + } + + if ($outlet_ids !== null && count($outlet_ids) > 500) { + throw new \InvalidArgumentException('invalid value for "$outlet_ids" when calling DbsApi.getOutletLicenses_0, number of items must be less than or equal to 500.'); + } + if ($outlet_ids !== null && count($outlet_ids) < 1) { + throw new \InvalidArgumentException('invalid value for "$outlet_ids" when calling DbsApi.getOutletLicenses_0, number of items must be greater than or equal to 1.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/outlets/licenses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $outlet_ids, + 'outletIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $ids, + 'ids', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOutlet_0 + * + * Информация об одной точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOutletResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOutlet_0($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet_0'][0]) + { + list($response) = $this->getOutlet_0WithHttpInfo($campaign_id, $outlet_id, $contentType); + return $response; + } + + /** + * Operation getOutlet_0WithHttpInfo + * + * Информация об одной точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOutletResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOutlet_0WithHttpInfo($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet_0'][0]) + { + $request = $this->getOutlet_0Request($campaign_id, $outlet_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOutletResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOutletResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOutletResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOutletResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOutletResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOutlet_0Async + * + * Информация об одной точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutlet_0Async($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet_0'][0]) + { + return $this->getOutlet_0AsyncWithHttpInfo($campaign_id, $outlet_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOutlet_0AsyncWithHttpInfo + * + * Информация об одной точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutlet_0AsyncWithHttpInfo($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOutletResponse'; + $request = $this->getOutlet_0Request($campaign_id, $outlet_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOutlet_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOutlet_0Request($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOutlet_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOutlet_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'outlet_id' is set + if ($outlet_id === null || (is_array($outlet_id) && count($outlet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $outlet_id when calling getOutlet_0' + ); + } + if ($outlet_id < 1) { + throw new \InvalidArgumentException('invalid value for "$outlet_id" when calling DbsApi.getOutlet_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/{outletId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($outlet_id !== null) { + $resourcePath = str_replace( + '{' . 'outletId' . '}', + ObjectSerializer::toPathValue($outlet_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOutlets_0 + * + * Информация о нескольких точках продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOutletsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOutlets_0($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets_0'][0]) + { + list($response) = $this->getOutlets_0WithHttpInfo($campaign_id, $page_token, $region_id, $shop_outlet_code, $region_id2, $contentType); + return $response; + } + + /** + * Operation getOutlets_0WithHttpInfo + * + * Информация о нескольких точках продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOutletsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOutlets_0WithHttpInfo($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets_0'][0]) + { + $request = $this->getOutlets_0Request($campaign_id, $page_token, $region_id, $shop_outlet_code, $region_id2, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOutletsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOutletsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOutletsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOutletsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOutletsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOutlets_0Async + * + * Информация о нескольких точках продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutlets_0Async($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets_0'][0]) + { + return $this->getOutlets_0AsyncWithHttpInfo($campaign_id, $page_token, $region_id, $shop_outlet_code, $region_id2, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOutlets_0AsyncWithHttpInfo + * + * Информация о нескольких точках продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutlets_0AsyncWithHttpInfo($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOutletsResponse'; + $request = $this->getOutlets_0Request($campaign_id, $page_token, $region_id, $shop_outlet_code, $region_id2, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOutlets_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOutlets_0Request($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOutlets_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getOutlets_0, must be bigger than or equal to 1.'); + } + + + + + + + $resourcePath = '/campaigns/{campaignId}/outlets'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'region_id', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_outlet_code, + 'shop_outlet_code', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id2, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPricesByOfferIds_2 + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPricesByOfferIds_2($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_2'][0]) + { + list($response) = $this->getPricesByOfferIds_2WithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + return $response; + } + + /** + * Operation getPricesByOfferIds_2WithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPricesByOfferIds_2WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_2'][0]) + { + $request = $this->getPricesByOfferIds_2Request($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPricesByOfferIds_2Async + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIds_2Async($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_2'][0]) + { + return $this->getPricesByOfferIds_2AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPricesByOfferIds_2AsyncWithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIds_2AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + $request = $this->getPricesByOfferIds_2Request($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPricesByOfferIds_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPricesByOfferIds_2Request($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPricesByOfferIds_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getPricesByOfferIds_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_prices_by_offer_ids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_prices_by_offer_ids_request)); + } else { + $httpBody = $get_prices_by_offer_ids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPrices_2 + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getPrices_2($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_2'][0]) + { + list($response) = $this->getPrices_2WithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType); + return $response; + } + + /** + * Operation getPrices_2WithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getPrices_2WithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_2'][0]) + { + $request = $this->getPrices_2Request($campaign_id, $page_token, $limit, $archived, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPrices_2Async + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPrices_2Async($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_2'][0]) + { + return $this->getPrices_2AsyncWithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPrices_2AsyncWithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPrices_2AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + $request = $this->getPrices_2Request($campaign_id, $page_token, $limit, $archived, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPrices_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getPrices_2Request($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPrices_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getPrices_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromoOffers_2 + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromoOffers_2($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_2'][0]) + { + list($response) = $this->getPromoOffers_2WithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getPromoOffers_2WithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromoOffers_2WithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_2'][0]) + { + $request = $this->getPromoOffers_2Request($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromoOffers_2Async + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffers_2Async($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_2'][0]) + { + return $this->getPromoOffers_2AsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromoOffers_2AsyncWithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffers_2AsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + $request = $this->getPromoOffers_2Request($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromoOffers_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromoOffers_2Request($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromoOffers_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getPromoOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_promo_offers_request' is set + if ($get_promo_offers_request === null || (is_array($get_promo_offers_request) && count($get_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_promo_offers_request when calling getPromoOffers_2' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/promos/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promo_offers_request)); + } else { + $httpBody = $get_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromos_2 + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromos_2($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_2'][0]) + { + list($response) = $this->getPromos_2WithHttpInfo($business_id, $get_promos_request, $contentType); + return $response; + } + + /** + * Operation getPromos_2WithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromos_2WithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_2'][0]) + { + $request = $this->getPromos_2Request($business_id, $get_promos_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromosResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromosResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromosResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromosResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromos_2Async + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromos_2Async($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_2'][0]) + { + return $this->getPromos_2AsyncWithHttpInfo($business_id, $get_promos_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromos_2AsyncWithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromos_2AsyncWithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + $request = $this->getPromos_2Request($business_id, $get_promos_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromos_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromos_2Request($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromos_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getPromos_2, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/promos'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promos_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promos_request)); + } else { + $httpBody = $get_promos_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getQualityRatingDetails_1 + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingDetailsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatingDetails_1($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_1'][0]) + { + list($response) = $this->getQualityRatingDetails_1WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getQualityRatingDetails_1WithHttpInfo + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingDetailsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatingDetails_1WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_1'][0]) + { + $request = $this->getQualityRatingDetails_1Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingDetailsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingDetailsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatingDetails_1Async + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingDetails_1Async($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_1'][0]) + { + return $this->getQualityRatingDetails_1AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatingDetails_1AsyncWithHttpInfo + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingDetails_1AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse'; + $request = $this->getQualityRatingDetails_1Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatingDetails_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatingDetails_1Request($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getQualityRatingDetails_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getQualityRatingDetails_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/ratings/quality/details'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getQualityRatings_2 + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatings_2($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_2'][0]) + { + list($response) = $this->getQualityRatings_2WithHttpInfo($business_id, $get_quality_rating_request, $contentType); + return $response; + } + + /** + * Operation getQualityRatings_2WithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatings_2WithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_2'][0]) + { + $request = $this->getQualityRatings_2Request($business_id, $get_quality_rating_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatings_2Async + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatings_2Async($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_2'][0]) + { + return $this->getQualityRatings_2AsyncWithHttpInfo($business_id, $get_quality_rating_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatings_2AsyncWithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatings_2AsyncWithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + $request = $this->getQualityRatings_2Request($business_id, $get_quality_rating_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatings_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatings_2Request($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getQualityRatings_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getQualityRatings_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quality_rating_request' is set + if ($get_quality_rating_request === null || (is_array($get_quality_rating_request) && count($get_quality_rating_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quality_rating_request when calling getQualityRatings_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/ratings/quality'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quality_rating_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quality_rating_request)); + } else { + $httpBody = $get_quality_rating_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReportInfo_1 + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReportInfo_1($report_id, string $contentType = self::contentTypes['getReportInfo_1'][0]) + { + list($response) = $this->getReportInfo_1WithHttpInfo($report_id, $contentType); + return $response; + } + + /** + * Operation getReportInfo_1WithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReportInfo_1WithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo_1'][0]) + { + $request = $this->getReportInfo_1Request($report_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReportInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReportInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReportInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReportInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReportInfo_1Async + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfo_1Async($report_id, string $contentType = self::contentTypes['getReportInfo_1'][0]) + { + return $this->getReportInfo_1AsyncWithHttpInfo($report_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReportInfo_1AsyncWithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfo_1AsyncWithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + $request = $this->getReportInfo_1Request($report_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReportInfo_1' + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReportInfo_1Request($report_id, string $contentType = self::contentTypes['getReportInfo_1'][0]) + { + + // verify the required parameter 'report_id' is set + if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $report_id when calling getReportInfo_1' + ); + } + + + $resourcePath = '/reports/info/{reportId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($report_id !== null) { + $resourcePath = str_replace( + '{' . 'reportId' . '}', + ObjectSerializer::toPathValue($report_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnApplication_1 + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnApplication_1($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_1'][0]) + { + list($response) = $this->getReturnApplication_1WithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturnApplication_1WithHttpInfo + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnApplication_1WithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_1'][0]) + { + $request = $this->getReturnApplication_1Request($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnApplication_1Async + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnApplication_1Async($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_1'][0]) + { + return $this->getReturnApplication_1AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnApplication_1AsyncWithHttpInfo + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnApplication_1AsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_1'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnApplication_1Request($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnApplication_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnApplication_1Request($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnApplication_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getReturnApplication_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnApplication_1' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnApplication_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/application'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnPhoto_1 + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnPhoto_1($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_1'][0]) + { + list($response) = $this->getReturnPhoto_1WithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + return $response; + } + + /** + * Operation getReturnPhoto_1WithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnPhoto_1WithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_1'][0]) + { + $request = $this->getReturnPhoto_1Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnPhoto_1Async + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhoto_1Async($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_1'][0]) + { + return $this->getReturnPhoto_1AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnPhoto_1AsyncWithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhoto_1AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_1'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnPhoto_1Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnPhoto_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnPhoto_1Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnPhoto_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getReturnPhoto_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnPhoto_1' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnPhoto_1' + ); + } + + // verify the required parameter 'item_id' is set + if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $item_id when calling getReturnPhoto_1' + ); + } + + // verify the required parameter 'image_hash' is set + if ($image_hash === null || (is_array($image_hash) && count($image_hash) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $image_hash when calling getReturnPhoto_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision/{itemId}/image/{imageHash}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + // path params + if ($item_id !== null) { + $resourcePath = str_replace( + '{' . 'itemId' . '}', + ObjectSerializer::toPathValue($item_id), + $resourcePath + ); + } + // path params + if ($image_hash !== null) { + $resourcePath = str_replace( + '{' . 'imageHash' . '}', + ObjectSerializer::toPathValue($image_hash), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturn_1 + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturn_1($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_1'][0]) + { + list($response) = $this->getReturn_1WithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturn_1WithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturn_1WithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_1'][0]) + { + $request = $this->getReturn_1Request($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturn_1Async + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturn_1Async($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_1'][0]) + { + return $this->getReturn_1AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturn_1AsyncWithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturn_1AsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + $request = $this->getReturn_1Request($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturn_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturn_1Request($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturn_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getReturn_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturn_1' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturn_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturns_1 + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturns_1($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_1'][0]) + { + list($response) = $this->getReturns_1WithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + return $response; + } + + /** + * Operation getReturns_1WithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturns_1WithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_1'][0]) + { + $request = $this->getReturns_1Request($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturns_1Async + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturns_1Async($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_1'][0]) + { + return $this->getReturns_1AsyncWithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturns_1AsyncWithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturns_1AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + $request = $this->getReturns_1Request($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturns_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturns_1Request($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturns_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getReturns_1, must be bigger than or equal to 1.'); + } + + + + if ($order_ids !== null && count($order_ids) > 50) { + throw new \InvalidArgumentException('invalid value for "$order_ids" when calling DbsApi.getReturns_1, number of items must be less than or equal to 50.'); + } + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/returns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $statuses, + 'statuses', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $type, + 'type', // param base name + 'ReturnType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date2, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date2, + 'to_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getStocks_2 + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getStocks_2($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_2'][0]) + { + list($response) = $this->getStocks_2WithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + return $response; + } + + /** + * Operation getStocks_2WithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getStocks_2WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_2'][0]) + { + $request = $this->getStocks_2Request($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehouseStocksResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehouseStocksResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getStocks_2Async + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocks_2Async($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_2'][0]) + { + return $this->getStocks_2AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getStocks_2AsyncWithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocks_2AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + $request = $this->getStocks_2Request($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getStocks_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getStocks_2Request($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getStocks_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getStocks_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_warehouse_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_warehouse_stocks_request)); + } else { + $httpBody = $get_warehouse_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappingEntries_3 + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedOfferMappingEntries_3($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_3'][0]) + { + list($response) = $this->getSuggestedOfferMappingEntries_3WithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappingEntries_3WithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedOfferMappingEntries_3WithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_3'][0]) + { + $request = $this->getSuggestedOfferMappingEntries_3Request($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappingEntries_3Async + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntries_3Async($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_3'][0]) + { + return $this->getSuggestedOfferMappingEntries_3AsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappingEntries_3AsyncWithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntries_3AsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + $request = $this->getSuggestedOfferMappingEntries_3Request($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappingEntries_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedOfferMappingEntries_3Request($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedOfferMappingEntries_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getSuggestedOfferMappingEntries_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_suggested_offer_mapping_entries_request' is set + if ($get_suggested_offer_mapping_entries_request === null || (is_array($get_suggested_offer_mapping_entries_request) && count($get_suggested_offer_mapping_entries_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_suggested_offer_mapping_entries_request when calling getSuggestedOfferMappingEntries_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mapping_entries_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mapping_entries_request)); + } else { + $httpBody = $get_suggested_offer_mapping_entries_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappings_0 + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getSuggestedOfferMappings_0($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_0'][0]) + { + list($response) = $this->getSuggestedOfferMappings_0WithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappings_0WithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getSuggestedOfferMappings_0WithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_0'][0]) + { + $request = $this->getSuggestedOfferMappings_0Request($business_id, $get_suggested_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappings_0Async + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappings_0Async($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_0'][0]) + { + return $this->getSuggestedOfferMappings_0AsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappings_0AsyncWithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappings_0AsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + $request = $this->getSuggestedOfferMappings_0Request($business_id, $get_suggested_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappings_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getSuggestedOfferMappings_0Request($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getSuggestedOfferMappings_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getSuggestedOfferMappings_0, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/offer-mappings/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mappings_request)); + } else { + $httpBody = $get_suggested_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedPrices_3 + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedPrices_3($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_3'][0]) + { + list($response) = $this->getSuggestedPrices_3WithHttpInfo($campaign_id, $suggest_prices_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedPrices_3WithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedPrices_3WithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_3'][0]) + { + $request = $this->getSuggestedPrices_3Request($campaign_id, $suggest_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SuggestPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SuggestPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SuggestPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SuggestPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedPrices_3Async + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPrices_3Async($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_3'][0]) + { + return $this->getSuggestedPrices_3AsyncWithHttpInfo($campaign_id, $suggest_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedPrices_3AsyncWithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPrices_3AsyncWithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + $request = $this->getSuggestedPrices_3Request($campaign_id, $suggest_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedPrices_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedPrices_3Request($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedPrices_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.getSuggestedPrices_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'suggest_prices_request' is set + if ($suggest_prices_request === null || (is_array($suggest_prices_request) && count($suggest_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $suggest_prices_request when calling getSuggestedPrices_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($suggest_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($suggest_prices_request)); + } else { + $httpBody = $suggest_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getWarehouses_1 + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getWarehouses_1($business_id, string $contentType = self::contentTypes['getWarehouses_1'][0]) + { + list($response) = $this->getWarehouses_1WithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getWarehouses_1WithHttpInfo + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getWarehouses_1WithHttpInfo($business_id, string $contentType = self::contentTypes['getWarehouses_1'][0]) + { + $request = $this->getWarehouses_1Request($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehousesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehousesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehousesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehousesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehousesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getWarehouses_1Async + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getWarehouses_1Async($business_id, string $contentType = self::contentTypes['getWarehouses_1'][0]) + { + return $this->getWarehouses_1AsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getWarehouses_1AsyncWithHttpInfo + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getWarehouses_1AsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getWarehouses_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehousesResponse'; + $request = $this->getWarehouses_1Request($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getWarehouses_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getWarehouses_1Request($business_id, string $contentType = self::contentTypes['getWarehouses_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getWarehouses_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.getWarehouses_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/warehouses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation provideOrderDigitalCodes_0 + * + * Передача ключей цифровых товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function provideOrderDigitalCodes_0($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes_0'][0]) + { + list($response) = $this->provideOrderDigitalCodes_0WithHttpInfo($campaign_id, $order_id, $provide_order_digital_codes_request, $contentType); + return $response; + } + + /** + * Operation provideOrderDigitalCodes_0WithHttpInfo + * + * Передача ключей цифровых товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function provideOrderDigitalCodes_0WithHttpInfo($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes_0'][0]) + { + $request = $this->provideOrderDigitalCodes_0Request($campaign_id, $order_id, $provide_order_digital_codes_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation provideOrderDigitalCodes_0Async + * + * Передача ключей цифровых товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderDigitalCodes_0Async($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes_0'][0]) + { + return $this->provideOrderDigitalCodes_0AsyncWithHttpInfo($campaign_id, $order_id, $provide_order_digital_codes_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation provideOrderDigitalCodes_0AsyncWithHttpInfo + * + * Передача ключей цифровых товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderDigitalCodes_0AsyncWithHttpInfo($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->provideOrderDigitalCodes_0Request($campaign_id, $order_id, $provide_order_digital_codes_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'provideOrderDigitalCodes_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function provideOrderDigitalCodes_0Request($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling provideOrderDigitalCodes_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.provideOrderDigitalCodes_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling provideOrderDigitalCodes_0' + ); + } + + // verify the required parameter 'provide_order_digital_codes_request' is set + if ($provide_order_digital_codes_request === null || (is_array($provide_order_digital_codes_request) && count($provide_order_digital_codes_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $provide_order_digital_codes_request when calling provideOrderDigitalCodes_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/deliverDigitalGoods'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($provide_order_digital_codes_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($provide_order_digital_codes_request)); + } else { + $httpBody = $provide_order_digital_codes_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation provideOrderItemIdentifiers_1 + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function provideOrderItemIdentifiers_1($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_1'][0]) + { + list($response) = $this->provideOrderItemIdentifiers_1WithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + return $response; + } + + /** + * Operation provideOrderItemIdentifiers_1WithHttpInfo + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function provideOrderItemIdentifiers_1WithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_1'][0]) + { + $request = $this->provideOrderItemIdentifiers_1Request($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation provideOrderItemIdentifiers_1Async + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderItemIdentifiers_1Async($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_1'][0]) + { + return $this->provideOrderItemIdentifiers_1AsyncWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation provideOrderItemIdentifiers_1AsyncWithHttpInfo + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderItemIdentifiers_1AsyncWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse'; + $request = $this->provideOrderItemIdentifiers_1Request($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'provideOrderItemIdentifiers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function provideOrderItemIdentifiers_1Request($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling provideOrderItemIdentifiers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.provideOrderItemIdentifiers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling provideOrderItemIdentifiers_1' + ); + } + + // verify the required parameter 'provide_order_item_identifiers_request' is set + if ($provide_order_item_identifiers_request === null || (is_array($provide_order_item_identifiers_request) && count($provide_order_item_identifiers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $provide_order_item_identifiers_request when calling provideOrderItemIdentifiers_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/identifiers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($provide_order_item_identifiers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($provide_order_item_identifiers_request)); + } else { + $httpBody = $provide_order_item_identifiers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForBusiness_0 + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForBusiness_0($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_0'][0]) + { + list($response) = $this->putBidsForBusiness_0WithHttpInfo($business_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForBusiness_0WithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForBusiness_0WithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_0'][0]) + { + $request = $this->putBidsForBusiness_0Request($business_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForBusiness_0Async + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusiness_0Async($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_0'][0]) + { + return $this->putBidsForBusiness_0AsyncWithHttpInfo($business_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForBusiness_0AsyncWithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusiness_0AsyncWithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForBusiness_0Request($business_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForBusiness_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForBusiness_0Request($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling putBidsForBusiness_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.putBidsForBusiness_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForBusiness_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForCampaign_0 + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForCampaign_0($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_0'][0]) + { + list($response) = $this->putBidsForCampaign_0WithHttpInfo($campaign_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForCampaign_0WithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForCampaign_0WithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_0'][0]) + { + $request = $this->putBidsForCampaign_0Request($campaign_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForCampaign_0Async + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaign_0Async($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_0'][0]) + { + return $this->putBidsForCampaign_0AsyncWithHttpInfo($campaign_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForCampaign_0AsyncWithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaign_0AsyncWithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForCampaign_0Request($campaign_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForCampaign_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForCampaign_0Request($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling putBidsForCampaign_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.putBidsForCampaign_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForCampaign_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation refreshFeed_0 + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function refreshFeed_0($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_0'][0]) + { + list($response) = $this->refreshFeed_0WithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation refreshFeed_0WithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function refreshFeed_0WithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_0'][0]) + { + $request = $this->refreshFeed_0Request($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation refreshFeed_0Async + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeed_0Async($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_0'][0]) + { + return $this->refreshFeed_0AsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation refreshFeed_0AsyncWithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeed_0AsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->refreshFeed_0Request($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'refreshFeed_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function refreshFeed_0Request($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling refreshFeed_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.refreshFeed_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling refreshFeed_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/refresh'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchModels_0 + * + * Поиск модели товара + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SearchModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchModels_0($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels_0'][0]) + { + list($response) = $this->searchModels_0WithHttpInfo($query, $region_id, $currency, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation searchModels_0WithHttpInfo + * + * Поиск модели товара + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SearchModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchModels_0WithHttpInfo($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels_0'][0]) + { + $request = $this->searchModels_0Request($query, $region_id, $currency, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SearchModelsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SearchModelsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SearchModelsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SearchModelsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SearchModelsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchModels_0Async + * + * Поиск модели товара + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchModels_0Async($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels_0'][0]) + { + return $this->searchModels_0AsyncWithHttpInfo($query, $region_id, $currency, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchModels_0AsyncWithHttpInfo + * + * Поиск модели товара + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchModels_0AsyncWithHttpInfo($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\SearchModelsResponse'; + $request = $this->searchModels_0Request($query, $region_id, $currency, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchModels_0' + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchModels_0Request($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels_0'][0]) + { + + // verify the required parameter 'query' is set + if ($query === null || (is_array($query) && count($query) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $query when calling searchModels_0' + ); + } + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchModels_0' + ); + } + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling DbsApi.searchModels_0, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/models'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionChildren_2 + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionChildren_2($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_2'][0]) + { + list($response) = $this->searchRegionChildren_2WithHttpInfo($region_id, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation searchRegionChildren_2WithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionChildren_2WithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_2'][0]) + { + $request = $this->searchRegionChildren_2Request($region_id, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionChildren_2Async + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildren_2Async($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_2'][0]) + { + return $this->searchRegionChildren_2AsyncWithHttpInfo($region_id, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionChildren_2AsyncWithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildren_2AsyncWithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + $request = $this->searchRegionChildren_2Request($region_id, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionChildren_2' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionChildren_2Request($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_2'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionChildren_2' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling DbsApi.searchRegionChildren_2, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/regions/{regionId}/children'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsById_2 + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsById_2($region_id, string $contentType = self::contentTypes['searchRegionsById_2'][0]) + { + list($response) = $this->searchRegionsById_2WithHttpInfo($region_id, $contentType); + return $response; + } + + /** + * Operation searchRegionsById_2WithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsById_2WithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById_2'][0]) + { + $request = $this->searchRegionsById_2Request($region_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsById_2Async + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsById_2Async($region_id, string $contentType = self::contentTypes['searchRegionsById_2'][0]) + { + return $this->searchRegionsById_2AsyncWithHttpInfo($region_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsById_2AsyncWithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsById_2AsyncWithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsById_2Request($region_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsById_2' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsById_2Request($region_id, string $contentType = self::contentTypes['searchRegionsById_2'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionsById_2' + ); + } + + + $resourcePath = '/regions/{regionId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsByName_2 + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsByName_2($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_2'][0]) + { + list($response) = $this->searchRegionsByName_2WithHttpInfo($name, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation searchRegionsByName_2WithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsByName_2WithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_2'][0]) + { + $request = $this->searchRegionsByName_2Request($name, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsByName_2Async + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByName_2Async($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_2'][0]) + { + return $this->searchRegionsByName_2AsyncWithHttpInfo($name, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsByName_2AsyncWithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByName_2AsyncWithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsByName_2Request($name, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsByName_2' + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsByName_2Request($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_2'][0]) + { + + // verify the required parameter 'name' is set + if ($name === null || (is_array($name) && count($name) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $name when calling searchRegionsByName_2' + ); + } + + + + + $resourcePath = '/regions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $name, + 'name', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendFileToChat_0 + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendFileToChat_0($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_0'][0]) + { + list($response) = $this->sendFileToChat_0WithHttpInfo($business_id, $chat_id, $file, $contentType); + return $response; + } + + /** + * Operation sendFileToChat_0WithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendFileToChat_0WithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_0'][0]) + { + $request = $this->sendFileToChat_0Request($business_id, $chat_id, $file, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendFileToChat_0Async + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChat_0Async($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_0'][0]) + { + return $this->sendFileToChat_0AsyncWithHttpInfo($business_id, $chat_id, $file, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendFileToChat_0AsyncWithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChat_0AsyncWithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendFileToChat_0Request($business_id, $chat_id, $file, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendFileToChat_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendFileToChat_0Request($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendFileToChat_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.sendFileToChat_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendFileToChat_0' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling DbsApi.sendFileToChat_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'file' is set + if ($file === null || (is_array($file) && count($file) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $file when calling sendFileToChat_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/file/send'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + // form params + if ($file !== null) { + $multipart = true; + $formParams['file'] = []; + $paramFiles = is_array($file) ? $file : [$file]; + foreach ($paramFiles as $paramFile) { + $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( + ObjectSerializer::toFormValue($paramFile), + 'rb' + ); + } + } + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendMessageToChat_0 + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendMessageToChat_0($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_0'][0]) + { + list($response) = $this->sendMessageToChat_0WithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType); + return $response; + } + + /** + * Operation sendMessageToChat_0WithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendMessageToChat_0WithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_0'][0]) + { + $request = $this->sendMessageToChat_0Request($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendMessageToChat_0Async + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChat_0Async($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_0'][0]) + { + return $this->sendMessageToChat_0AsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendMessageToChat_0AsyncWithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChat_0AsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendMessageToChat_0Request($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendMessageToChat_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendMessageToChat_0Request($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendMessageToChat_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.sendMessageToChat_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendMessageToChat_0' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling DbsApi.sendMessageToChat_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'send_message_to_chat_request' is set + if ($send_message_to_chat_request === null || (is_array($send_message_to_chat_request) && count($send_message_to_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $send_message_to_chat_request when calling sendMessageToChat_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/message'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($send_message_to_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($send_message_to_chat_request)); + } else { + $httpBody = $send_message_to_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setFeedParams_0 + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function setFeedParams_0($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_0'][0]) + { + list($response) = $this->setFeedParams_0WithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType); + return $response; + } + + /** + * Operation setFeedParams_0WithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function setFeedParams_0WithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_0'][0]) + { + $request = $this->setFeedParams_0Request($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setFeedParams_0Async + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParams_0Async($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_0'][0]) + { + return $this->setFeedParams_0AsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setFeedParams_0AsyncWithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParams_0AsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setFeedParams_0Request($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setFeedParams_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function setFeedParams_0Request($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setFeedParams_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.setFeedParams_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling setFeedParams_0' + ); + } + + // verify the required parameter 'set_feed_params_request' is set + if ($set_feed_params_request === null || (is_array($set_feed_params_request) && count($set_feed_params_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_feed_params_request when calling setFeedParams_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/params'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_feed_params_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_feed_params_request)); + } else { + $httpBody = $set_feed_params_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderBoxLayout_2 + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SetOrderBoxLayoutResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderBoxLayout_2($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_2'][0]) + { + list($response) = $this->setOrderBoxLayout_2WithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + return $response; + } + + /** + * Operation setOrderBoxLayout_2WithHttpInfo + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SetOrderBoxLayoutResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderBoxLayout_2WithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_2'][0]) + { + $request = $this->setOrderBoxLayout_2Request($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SetOrderBoxLayoutResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SetOrderBoxLayoutResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderBoxLayout_2Async + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderBoxLayout_2Async($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_2'][0]) + { + return $this->setOrderBoxLayout_2AsyncWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderBoxLayout_2AsyncWithHttpInfo + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderBoxLayout_2AsyncWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse'; + $request = $this->setOrderBoxLayout_2Request($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderBoxLayout_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderBoxLayout_2Request($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderBoxLayout_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.setOrderBoxLayout_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderBoxLayout_2' + ); + } + + // verify the required parameter 'set_order_box_layout_request' is set + if ($set_order_box_layout_request === null || (is_array($set_order_box_layout_request) && count($set_order_box_layout_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_box_layout_request when calling setOrderBoxLayout_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/boxes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_box_layout_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_box_layout_request)); + } else { + $httpBody = $set_order_box_layout_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderDeliveryDate_0 + * + * Изменение даты доставки заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderDeliveryDate_0($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate_0'][0]) + { + list($response) = $this->setOrderDeliveryDate_0WithHttpInfo($campaign_id, $order_id, $set_order_delivery_date_request, $contentType); + return $response; + } + + /** + * Operation setOrderDeliveryDate_0WithHttpInfo + * + * Изменение даты доставки заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderDeliveryDate_0WithHttpInfo($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate_0'][0]) + { + $request = $this->setOrderDeliveryDate_0Request($campaign_id, $order_id, $set_order_delivery_date_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderDeliveryDate_0Async + * + * Изменение даты доставки заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderDeliveryDate_0Async($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate_0'][0]) + { + return $this->setOrderDeliveryDate_0AsyncWithHttpInfo($campaign_id, $order_id, $set_order_delivery_date_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderDeliveryDate_0AsyncWithHttpInfo + * + * Изменение даты доставки заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderDeliveryDate_0AsyncWithHttpInfo($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setOrderDeliveryDate_0Request($campaign_id, $order_id, $set_order_delivery_date_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderDeliveryDate_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderDeliveryDate_0Request($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderDeliveryDate_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.setOrderDeliveryDate_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderDeliveryDate_0' + ); + } + + // verify the required parameter 'set_order_delivery_date_request' is set + if ($set_order_delivery_date_request === null || (is_array($set_order_delivery_date_request) && count($set_order_delivery_date_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_delivery_date_request when calling setOrderDeliveryDate_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/date'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_delivery_date_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_delivery_date_request)); + } else { + $httpBody = $set_order_delivery_date_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderDeliveryTrackCode_0 + * + * Передача трек‑номера посылки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderDeliveryTrackCode_0($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode_0'][0]) + { + list($response) = $this->setOrderDeliveryTrackCode_0WithHttpInfo($campaign_id, $order_id, $set_order_delivery_track_code_request, $contentType); + return $response; + } + + /** + * Operation setOrderDeliveryTrackCode_0WithHttpInfo + * + * Передача трек‑номера посылки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderDeliveryTrackCode_0WithHttpInfo($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode_0'][0]) + { + $request = $this->setOrderDeliveryTrackCode_0Request($campaign_id, $order_id, $set_order_delivery_track_code_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderDeliveryTrackCode_0Async + * + * Передача трек‑номера посылки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderDeliveryTrackCode_0Async($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode_0'][0]) + { + return $this->setOrderDeliveryTrackCode_0AsyncWithHttpInfo($campaign_id, $order_id, $set_order_delivery_track_code_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderDeliveryTrackCode_0AsyncWithHttpInfo + * + * Передача трек‑номера посылки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderDeliveryTrackCode_0AsyncWithHttpInfo($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setOrderDeliveryTrackCode_0Request($campaign_id, $order_id, $set_order_delivery_track_code_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderDeliveryTrackCode_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderDeliveryTrackCode_0Request($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderDeliveryTrackCode_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.setOrderDeliveryTrackCode_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderDeliveryTrackCode_0' + ); + } + + // verify the required parameter 'set_order_delivery_track_code_request' is set + if ($set_order_delivery_track_code_request === null || (is_array($set_order_delivery_track_code_request) && count($set_order_delivery_track_code_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_delivery_track_code_request when calling setOrderDeliveryTrackCode_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/track'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_delivery_track_code_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_delivery_track_code_request)); + } else { + $httpBody = $set_order_delivery_track_code_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderShipmentBoxes_1 + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SetOrderShipmentBoxesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderShipmentBoxes_1($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_1'][0]) + { + list($response) = $this->setOrderShipmentBoxes_1WithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + return $response; + } + + /** + * Operation setOrderShipmentBoxes_1WithHttpInfo + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SetOrderShipmentBoxesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderShipmentBoxes_1WithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_1'][0]) + { + $request = $this->setOrderShipmentBoxes_1Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderShipmentBoxes_1Async + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderShipmentBoxes_1Async($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_1'][0]) + { + return $this->setOrderShipmentBoxes_1AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderShipmentBoxes_1AsyncWithHttpInfo + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderShipmentBoxes_1AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse'; + $request = $this->setOrderShipmentBoxes_1Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderShipmentBoxes_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderShipmentBoxes_1Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderShipmentBoxes_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.setOrderShipmentBoxes_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderShipmentBoxes_1' + ); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling setOrderShipmentBoxes_1' + ); + } + + // verify the required parameter 'set_order_shipment_boxes_request' is set + if ($set_order_shipment_boxes_request === null || (is_array($set_order_shipment_boxes_request) && count($set_order_shipment_boxes_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_shipment_boxes_request when calling setOrderShipmentBoxes_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_shipment_boxes_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_shipment_boxes_request)); + } else { + $httpBody = $set_order_shipment_boxes_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setReturnDecision_0 + * + * Принятие или изменение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setReturnDecision_0($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision_0'][0]) + { + list($response) = $this->setReturnDecision_0WithHttpInfo($campaign_id, $order_id, $return_id, $set_return_decision_request, $contentType); + return $response; + } + + /** + * Operation setReturnDecision_0WithHttpInfo + * + * Принятие или изменение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setReturnDecision_0WithHttpInfo($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision_0'][0]) + { + $request = $this->setReturnDecision_0Request($campaign_id, $order_id, $return_id, $set_return_decision_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setReturnDecision_0Async + * + * Принятие или изменение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setReturnDecision_0Async($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision_0'][0]) + { + return $this->setReturnDecision_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $set_return_decision_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setReturnDecision_0AsyncWithHttpInfo + * + * Принятие или изменение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setReturnDecision_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setReturnDecision_0Request($campaign_id, $order_id, $return_id, $set_return_decision_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setReturnDecision_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setReturnDecision_0Request($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setReturnDecision_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.setReturnDecision_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setReturnDecision_0' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling setReturnDecision_0' + ); + } + + // verify the required parameter 'set_return_decision_request' is set + if ($set_return_decision_request === null || (is_array($set_return_decision_request) && count($set_return_decision_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_return_decision_request when calling setReturnDecision_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_return_decision_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_return_decision_request)); + } else { + $httpBody = $set_return_decision_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation skipGoodsFeedbacksReaction_2 + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function skipGoodsFeedbacksReaction_2($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_2'][0]) + { + list($response) = $this->skipGoodsFeedbacksReaction_2WithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType); + return $response; + } + + /** + * Operation skipGoodsFeedbacksReaction_2WithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function skipGoodsFeedbacksReaction_2WithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_2'][0]) + { + $request = $this->skipGoodsFeedbacksReaction_2Request($business_id, $skip_goods_feedback_reaction_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation skipGoodsFeedbacksReaction_2Async + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReaction_2Async($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_2'][0]) + { + return $this->skipGoodsFeedbacksReaction_2AsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation skipGoodsFeedbacksReaction_2AsyncWithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReaction_2AsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->skipGoodsFeedbacksReaction_2Request($business_id, $skip_goods_feedback_reaction_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'skipGoodsFeedbacksReaction_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function skipGoodsFeedbacksReaction_2Request($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling skipGoodsFeedbacksReaction_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.skipGoodsFeedbacksReaction_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'skip_goods_feedback_reaction_request' is set + if ($skip_goods_feedback_reaction_request === null || (is_array($skip_goods_feedback_reaction_request) && count($skip_goods_feedback_reaction_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $skip_goods_feedback_reaction_request when calling skipGoodsFeedbacksReaction_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/skip-reaction'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($skip_goods_feedback_reaction_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($skip_goods_feedback_reaction_request)); + } else { + $httpBody = $skip_goods_feedback_reaction_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation submitReturnDecision_0 + * + * Подтверждение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function submitReturnDecision_0($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision_0'][0]) + { + list($response) = $this->submitReturnDecision_0WithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation submitReturnDecision_0WithHttpInfo + * + * Подтверждение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function submitReturnDecision_0WithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision_0'][0]) + { + $request = $this->submitReturnDecision_0Request($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation submitReturnDecision_0Async + * + * Подтверждение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function submitReturnDecision_0Async($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision_0'][0]) + { + return $this->submitReturnDecision_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation submitReturnDecision_0AsyncWithHttpInfo + * + * Подтверждение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function submitReturnDecision_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->submitReturnDecision_0Request($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'submitReturnDecision_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function submitReturnDecision_0Request($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling submitReturnDecision_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.submitReturnDecision_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling submitReturnDecision_0' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling submitReturnDecision_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision/submit'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateBusinessPrices_2 + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateBusinessPrices_2($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_2'][0]) + { + list($response) = $this->updateBusinessPrices_2WithHttpInfo($business_id, $update_business_prices_request, $contentType); + return $response; + } + + /** + * Operation updateBusinessPrices_2WithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateBusinessPrices_2WithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_2'][0]) + { + $request = $this->updateBusinessPrices_2Request($business_id, $update_business_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateBusinessPrices_2Async + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPrices_2Async($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_2'][0]) + { + return $this->updateBusinessPrices_2AsyncWithHttpInfo($business_id, $update_business_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateBusinessPrices_2AsyncWithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPrices_2AsyncWithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateBusinessPrices_2Request($business_id, $update_business_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateBusinessPrices_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateBusinessPrices_2Request($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateBusinessPrices_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.updateBusinessPrices_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_business_prices_request' is set + if ($update_business_prices_request === null || (is_array($update_business_prices_request) && count($update_business_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_business_prices_request when calling updateBusinessPrices_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_business_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_business_prices_request)); + } else { + $httpBody = $update_business_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateCampaignOffers_0 + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateCampaignOffers_0($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_0'][0]) + { + list($response) = $this->updateCampaignOffers_0WithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation updateCampaignOffers_0WithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateCampaignOffers_0WithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_0'][0]) + { + $request = $this->updateCampaignOffers_0Request($campaign_id, $update_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateCampaignOffers_0Async + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffers_0Async($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_0'][0]) + { + return $this->updateCampaignOffers_0AsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateCampaignOffers_0AsyncWithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffers_0AsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateCampaignOffers_0Request($campaign_id, $update_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateCampaignOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateCampaignOffers_0Request($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateCampaignOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateCampaignOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_campaign_offers_request' is set + if ($update_campaign_offers_request === null || (is_array($update_campaign_offers_request) && count($update_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_campaign_offers_request when calling updateCampaignOffers_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_campaign_offers_request)); + } else { + $httpBody = $update_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateGoodsFeedbackComment_2 + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateGoodsFeedbackComment_2($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_2'][0]) + { + list($response) = $this->updateGoodsFeedbackComment_2WithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation updateGoodsFeedbackComment_2WithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateGoodsFeedbackComment_2WithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_2'][0]) + { + $request = $this->updateGoodsFeedbackComment_2Request($business_id, $update_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateGoodsFeedbackComment_2Async + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackComment_2Async($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_2'][0]) + { + return $this->updateGoodsFeedbackComment_2AsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateGoodsFeedbackComment_2AsyncWithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackComment_2AsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + $request = $this->updateGoodsFeedbackComment_2Request($business_id, $update_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateGoodsFeedbackComment_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateGoodsFeedbackComment_2Request($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateGoodsFeedbackComment_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.updateGoodsFeedbackComment_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_goods_feedback_comment_request' is set + if ($update_goods_feedback_comment_request === null || (is_array($update_goods_feedback_comment_request) && count($update_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_goods_feedback_comment_request when calling updateGoodsFeedbackComment_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_goods_feedback_comment_request)); + } else { + $httpBody = $update_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferContent_0 + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferContent_0($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_0'][0]) + { + list($response) = $this->updateOfferContent_0WithHttpInfo($business_id, $update_offer_content_request, $contentType); + return $response; + } + + /** + * Operation updateOfferContent_0WithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferContent_0WithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_0'][0]) + { + $request = $this->updateOfferContent_0Request($business_id, $update_offer_content_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferContentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferContentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferContent_0Async + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContent_0Async($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_0'][0]) + { + return $this->updateOfferContent_0AsyncWithHttpInfo($business_id, $update_offer_content_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferContent_0AsyncWithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContent_0AsyncWithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + $request = $this->updateOfferContent_0Request($business_id, $update_offer_content_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferContent_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferContent_0Request($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferContent_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.updateOfferContent_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_content_request' is set + if ($update_offer_content_request === null || (is_array($update_offer_content_request) && count($update_offer_content_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_content_request when calling updateOfferContent_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-cards/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_content_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_content_request)); + } else { + $httpBody = $update_offer_content_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappingEntries_3 + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function updateOfferMappingEntries_3($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_3'][0]) + { + list($response) = $this->updateOfferMappingEntries_3WithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappingEntries_3WithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function updateOfferMappingEntries_3WithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_3'][0]) + { + $request = $this->updateOfferMappingEntries_3Request($campaign_id, $update_offer_mapping_entry_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappingEntries_3Async + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntries_3Async($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_3'][0]) + { + return $this->updateOfferMappingEntries_3AsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappingEntries_3AsyncWithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntries_3AsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOfferMappingEntries_3Request($campaign_id, $update_offer_mapping_entry_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappingEntries_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function updateOfferMappingEntries_3Request($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOfferMappingEntries_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateOfferMappingEntries_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mapping_entry_request' is set + if ($update_offer_mapping_entry_request === null || (is_array($update_offer_mapping_entry_request) && count($update_offer_mapping_entry_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mapping_entry_request when calling updateOfferMappingEntries_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mapping_entry_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mapping_entry_request)); + } else { + $httpBody = $update_offer_mapping_entry_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappings_0 + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferMappings_0($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_0'][0]) + { + list($response) = $this->updateOfferMappings_0WithHttpInfo($business_id, $update_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappings_0WithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferMappings_0WithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_0'][0]) + { + $request = $this->updateOfferMappings_0Request($business_id, $update_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappings_0Async + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappings_0Async($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_0'][0]) + { + return $this->updateOfferMappings_0AsyncWithHttpInfo($business_id, $update_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappings_0AsyncWithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappings_0AsyncWithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + $request = $this->updateOfferMappings_0Request($business_id, $update_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappings_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferMappings_0Request($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferMappings_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.updateOfferMappings_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mappings_request' is set + if ($update_offer_mappings_request === null || (is_array($update_offer_mappings_request) && count($update_offer_mappings_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mappings_request when calling updateOfferMappings_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mappings_request)); + } else { + $httpBody = $update_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderItems_1 + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function updateOrderItems_1($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_1'][0]) + { + $this->updateOrderItems_1WithHttpInfo($campaign_id, $order_id, $update_order_item_request, $contentType); + } + + /** + * Operation updateOrderItems_1WithHttpInfo + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderItems_1WithHttpInfo($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_1'][0]) + { + $request = $this->updateOrderItems_1Request($campaign_id, $order_id, $update_order_item_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderItems_1Async + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderItems_1Async($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_1'][0]) + { + return $this->updateOrderItems_1AsyncWithHttpInfo($campaign_id, $order_id, $update_order_item_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderItems_1AsyncWithHttpInfo + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderItems_1AsyncWithHttpInfo($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_1'][0]) + { + $returnType = ''; + $request = $this->updateOrderItems_1Request($campaign_id, $order_id, $update_order_item_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderItems_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderItems_1Request($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderItems_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateOrderItems_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderItems_1' + ); + } + + // verify the required parameter 'update_order_item_request' is set + if ($update_order_item_request === null || (is_array($update_order_item_request) && count($update_order_item_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_item_request when calling updateOrderItems_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/items'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_item_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_item_request)); + } else { + $httpBody = $update_order_item_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStatus_1 + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOrderStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStatus_1($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_1'][0]) + { + list($response) = $this->updateOrderStatus_1WithHttpInfo($campaign_id, $order_id, $update_order_status_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStatus_1WithHttpInfo + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOrderStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStatus_1WithHttpInfo($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_1'][0]) + { + $request = $this->updateOrderStatus_1Request($campaign_id, $order_id, $update_order_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOrderStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOrderStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOrderStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOrderStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStatus_1Async + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatus_1Async($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_1'][0]) + { + return $this->updateOrderStatus_1AsyncWithHttpInfo($campaign_id, $order_id, $update_order_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStatus_1AsyncWithHttpInfo + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatus_1AsyncWithHttpInfo($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusResponse'; + $request = $this->updateOrderStatus_1Request($campaign_id, $order_id, $update_order_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStatus_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStatus_1Request($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStatus_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateOrderStatus_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderStatus_1' + ); + } + + // verify the required parameter 'update_order_status_request' is set + if ($update_order_status_request === null || (is_array($update_order_status_request) && count($update_order_status_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_status_request when calling updateOrderStatus_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_status_request)); + } else { + $httpBody = $update_order_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStatuses_1 + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOrderStatusesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStatuses_1($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_1'][0]) + { + list($response) = $this->updateOrderStatuses_1WithHttpInfo($campaign_id, $update_order_statuses_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStatuses_1WithHttpInfo + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOrderStatusesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStatuses_1WithHttpInfo($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_1'][0]) + { + $request = $this->updateOrderStatuses_1Request($campaign_id, $update_order_statuses_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOrderStatusesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOrderStatusesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOrderStatusesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOrderStatusesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStatuses_1Async + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatuses_1Async($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_1'][0]) + { + return $this->updateOrderStatuses_1AsyncWithHttpInfo($campaign_id, $update_order_statuses_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStatuses_1AsyncWithHttpInfo + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatuses_1AsyncWithHttpInfo($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusesResponse'; + $request = $this->updateOrderStatuses_1Request($campaign_id, $update_order_statuses_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStatuses_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStatuses_1Request($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStatuses_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateOrderStatuses_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_order_statuses_request' is set + if ($update_order_statuses_request === null || (is_array($update_order_statuses_request) && count($update_order_statuses_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_statuses_request when calling updateOrderStatuses_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/status-update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_statuses_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_statuses_request)); + } else { + $httpBody = $update_order_statuses_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStorageLimit_0 + * + * Продление срока хранения заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStorageLimit_0($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit_0'][0]) + { + list($response) = $this->updateOrderStorageLimit_0WithHttpInfo($campaign_id, $order_id, $update_order_storage_limit_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStorageLimit_0WithHttpInfo + * + * Продление срока хранения заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStorageLimit_0WithHttpInfo($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit_0'][0]) + { + $request = $this->updateOrderStorageLimit_0Request($campaign_id, $order_id, $update_order_storage_limit_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStorageLimit_0Async + * + * Продление срока хранения заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStorageLimit_0Async($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit_0'][0]) + { + return $this->updateOrderStorageLimit_0AsyncWithHttpInfo($campaign_id, $order_id, $update_order_storage_limit_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStorageLimit_0AsyncWithHttpInfo + * + * Продление срока хранения заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStorageLimit_0AsyncWithHttpInfo($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOrderStorageLimit_0Request($campaign_id, $order_id, $update_order_storage_limit_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStorageLimit_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStorageLimit_0Request($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStorageLimit_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateOrderStorageLimit_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderStorageLimit_0' + ); + } + + // verify the required parameter 'update_order_storage_limit_request' is set + if ($update_order_storage_limit_request === null || (is_array($update_order_storage_limit_request) && count($update_order_storage_limit_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_storage_limit_request when calling updateOrderStorageLimit_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/storage-limit'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_storage_limit_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_storage_limit_request)); + } else { + $httpBody = $update_order_storage_limit_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOutletLicenses_0 + * + * Создание и изменение лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOutletLicenses_0($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses_0'][0]) + { + list($response) = $this->updateOutletLicenses_0WithHttpInfo($campaign_id, $update_outlet_license_request, $contentType); + return $response; + } + + /** + * Operation updateOutletLicenses_0WithHttpInfo + * + * Создание и изменение лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOutletLicenses_0WithHttpInfo($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses_0'][0]) + { + $request = $this->updateOutletLicenses_0Request($campaign_id, $update_outlet_license_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOutletLicenses_0Async + * + * Создание и изменение лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOutletLicenses_0Async($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses_0'][0]) + { + return $this->updateOutletLicenses_0AsyncWithHttpInfo($campaign_id, $update_outlet_license_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOutletLicenses_0AsyncWithHttpInfo + * + * Создание и изменение лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOutletLicenses_0AsyncWithHttpInfo($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOutletLicenses_0Request($campaign_id, $update_outlet_license_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOutletLicenses_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOutletLicenses_0Request($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOutletLicenses_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateOutletLicenses_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_outlet_license_request' is set + if ($update_outlet_license_request === null || (is_array($update_outlet_license_request) && count($update_outlet_license_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_outlet_license_request when calling updateOutletLicenses_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/licenses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_outlet_license_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_outlet_license_request)); + } else { + $httpBody = $update_outlet_license_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOutlet_0 + * + * Изменение информации о точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOutlet_0($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet_0'][0]) + { + list($response) = $this->updateOutlet_0WithHttpInfo($campaign_id, $outlet_id, $change_outlet_request, $contentType); + return $response; + } + + /** + * Operation updateOutlet_0WithHttpInfo + * + * Изменение информации о точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOutlet_0WithHttpInfo($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet_0'][0]) + { + $request = $this->updateOutlet_0Request($campaign_id, $outlet_id, $change_outlet_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOutlet_0Async + * + * Изменение информации о точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOutlet_0Async($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet_0'][0]) + { + return $this->updateOutlet_0AsyncWithHttpInfo($campaign_id, $outlet_id, $change_outlet_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOutlet_0AsyncWithHttpInfo + * + * Изменение информации о точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOutlet_0AsyncWithHttpInfo($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOutlet_0Request($campaign_id, $outlet_id, $change_outlet_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOutlet_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOutlet_0Request($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOutlet_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateOutlet_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'outlet_id' is set + if ($outlet_id === null || (is_array($outlet_id) && count($outlet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $outlet_id when calling updateOutlet_0' + ); + } + if ($outlet_id < 1) { + throw new \InvalidArgumentException('invalid value for "$outlet_id" when calling DbsApi.updateOutlet_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'change_outlet_request' is set + if ($change_outlet_request === null || (is_array($change_outlet_request) && count($change_outlet_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $change_outlet_request when calling updateOutlet_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/{outletId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($outlet_id !== null) { + $resourcePath = str_replace( + '{' . 'outletId' . '}', + ObjectSerializer::toPathValue($outlet_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($change_outlet_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($change_outlet_request)); + } else { + $httpBody = $change_outlet_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePrices_2 + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePrices_2($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_2'][0]) + { + list($response) = $this->updatePrices_2WithHttpInfo($campaign_id, $update_prices_request, $contentType); + return $response; + } + + /** + * Operation updatePrices_2WithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePrices_2WithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_2'][0]) + { + $request = $this->updatePrices_2Request($campaign_id, $update_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePrices_2Async + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePrices_2Async($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_2'][0]) + { + return $this->updatePrices_2AsyncWithHttpInfo($campaign_id, $update_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePrices_2AsyncWithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePrices_2AsyncWithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updatePrices_2Request($campaign_id, $update_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePrices_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePrices_2Request($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updatePrices_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updatePrices_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_prices_request' is set + if ($update_prices_request === null || (is_array($update_prices_request) && count($update_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_prices_request when calling updatePrices_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_prices_request)); + } else { + $httpBody = $update_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePromoOffers_2 + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePromoOffers_2($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_2'][0]) + { + list($response) = $this->updatePromoOffers_2WithHttpInfo($business_id, $update_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation updatePromoOffers_2WithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePromoOffers_2WithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_2'][0]) + { + $request = $this->updatePromoOffers_2Request($business_id, $update_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdatePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdatePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePromoOffers_2Async + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffers_2Async($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_2'][0]) + { + return $this->updatePromoOffers_2AsyncWithHttpInfo($business_id, $update_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePromoOffers_2AsyncWithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffers_2AsyncWithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + $request = $this->updatePromoOffers_2Request($business_id, $update_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePromoOffers_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePromoOffers_2Request($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updatePromoOffers_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling DbsApi.updatePromoOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_promo_offers_request' is set + if ($update_promo_offers_request === null || (is_array($update_promo_offers_request) && count($update_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_promo_offers_request when calling updatePromoOffers_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_promo_offers_request)); + } else { + $httpBody = $update_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateStocks_1 + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateStocks_1($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_1'][0]) + { + list($response) = $this->updateStocks_1WithHttpInfo($campaign_id, $update_stocks_request, $contentType); + return $response; + } + + /** + * Operation updateStocks_1WithHttpInfo + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateStocks_1WithHttpInfo($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_1'][0]) + { + $request = $this->updateStocks_1Request($campaign_id, $update_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateStocks_1Async + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateStocks_1Async($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_1'][0]) + { + return $this->updateStocks_1AsyncWithHttpInfo($campaign_id, $update_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateStocks_1AsyncWithHttpInfo + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateStocks_1AsyncWithHttpInfo($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateStocks_1Request($campaign_id, $update_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateStocks_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateStocks_1Request($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateStocks_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling DbsApi.updateStocks_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_stocks_request' is set + if ($update_stocks_request === null || (is_array($update_stocks_request) && count($update_stocks_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_stocks_request when calling updateStocks_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_stocks_request)); + } else { + $httpBody = $update_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/DeliveryServicesApi.php b/erp24/lib/yandex_market_api/Api/DeliveryServicesApi.php new file mode 100644 index 00000000..b23e554a --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/DeliveryServicesApi.php @@ -0,0 +1,650 @@ + [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getDeliveryServices + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetDeliveryServicesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getDeliveryServices(string $contentType = self::contentTypes['getDeliveryServices'][0]) + { + list($response) = $this->getDeliveryServicesWithHttpInfo($contentType); + return $response; + } + + /** + * Operation getDeliveryServicesWithHttpInfo + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetDeliveryServicesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getDeliveryServicesWithHttpInfo(string $contentType = self::contentTypes['getDeliveryServices'][0]) + { + $request = $this->getDeliveryServicesRequest($contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetDeliveryServicesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetDeliveryServicesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetDeliveryServicesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetDeliveryServicesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetDeliveryServicesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getDeliveryServicesAsync + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDeliveryServicesAsync(string $contentType = self::contentTypes['getDeliveryServices'][0]) + { + return $this->getDeliveryServicesAsyncWithHttpInfo($contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getDeliveryServicesAsyncWithHttpInfo + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDeliveryServicesAsyncWithHttpInfo(string $contentType = self::contentTypes['getDeliveryServices'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetDeliveryServicesResponse'; + $request = $this->getDeliveryServicesRequest($contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getDeliveryServices' + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getDeliveryServicesRequest(string $contentType = self::contentTypes['getDeliveryServices'][0]) + { + + + $resourcePath = '/delivery/services'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/ExpressApi.php b/erp24/lib/yandex_market_api/Api/ExpressApi.php new file mode 100644 index 00000000..013fb78d --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/ExpressApi.php @@ -0,0 +1,59563 @@ + [ + 'application/json', + ], + 'addOffersToArchive_3' => [ + 'application/json', + ], + 'calculateTariffs_3' => [ + 'application/json', + ], + 'confirmBusinessPrices_3' => [ + 'application/json', + ], + 'confirmCampaignPrices_3' => [ + 'application/json', + ], + 'createChat_3' => [ + 'application/json', + ], + 'deleteCampaignOffers_3' => [ + 'application/json', + ], + 'deleteGoodsFeedbackComment_3' => [ + 'application/json', + ], + 'deleteHiddenOffers_3' => [ + 'application/json', + ], + 'deleteOffersFromArchive_3' => [ + 'application/json', + ], + 'deleteOffers_3' => [ + 'application/json', + ], + 'deletePromoOffers_3' => [ + 'application/json', + ], + 'generateBoostConsolidatedReport_3' => [ + 'application/json', + ], + 'generateCompetitorsPositionReport_3' => [ + 'application/json', + ], + 'generateGoodsFeedbackReport_3' => [ + 'application/json', + ], + 'generateGoodsRealizationReport_2' => [ + 'application/json', + ], + 'generateMassOrderLabelsReport_2' => [ + 'application/json', + ], + 'generateOrderLabel_2' => [ + 'application/json', + ], + 'generateOrderLabels_2' => [ + 'application/json', + ], + 'generatePricesReport_3' => [ + 'application/json', + ], + 'generateShelfsStatisticsReport_3' => [ + 'application/json', + ], + 'generateShowsSalesReport_3' => [ + 'application/json', + ], + 'generateStocksOnWarehousesReport_3' => [ + 'application/json', + ], + 'generateUnitedMarketplaceServicesReport_3' => [ + 'application/json', + ], + 'generateUnitedNettingReport_3' => [ + 'application/json', + ], + 'generateUnitedOrdersReport_3' => [ + 'application/json', + ], + 'getAllOffers_2' => [ + 'application/json', + ], + 'getBidsInfoForBusiness_3' => [ + 'application/json', + ], + 'getBidsRecommendations_3' => [ + 'application/json', + ], + 'getBusinessQuarantineOffers_3' => [ + 'application/json', + ], + 'getBusinessSettings_3' => [ + 'application/json', + ], + 'getCampaignLogins_1' => [ + 'application/json', + ], + 'getCampaignOffers_3' => [ + 'application/json', + ], + 'getCampaignQuarantineOffers_3' => [ + 'application/json', + ], + 'getCampaignRegion_3' => [ + 'application/json', + ], + 'getCampaignSettings_2' => [ + 'application/json', + ], + 'getCampaign_1' => [ + 'application/json', + ], + 'getCampaignsByLogin_1' => [ + 'application/json', + ], + 'getCampaigns_1' => [ + 'application/json', + ], + 'getCategoriesMaxSaleQuantum_3' => [ + 'application/json', + ], + 'getCategoriesTree_3' => [ + 'application/json', + ], + 'getCategoryContentParameters_3' => [ + 'application/json', + ], + 'getChatHistory_3' => [ + 'application/json', + ], + 'getChats_3' => [ + 'application/json', + ], + 'getDeliveryServices_2' => [ + 'application/json', + ], + 'getFeedIndexLogs_2' => [ + 'application/json', + ], + 'getFeed_2' => [ + 'application/json', + ], + 'getFeedbackAndCommentUpdates_3' => [ + 'application/json', + ], + 'getFeeds_2' => [ + 'application/json', + ], + 'getGoodsFeedbackComments_3' => [ + 'application/json', + ], + 'getGoodsFeedbacks_3' => [ + 'application/json', + ], + 'getGoodsStats_2' => [ + 'application/json', + ], + 'getHiddenOffers_3' => [ + 'application/json', + ], + 'getOfferCardsContentStatus_3' => [ + 'application/json', + ], + 'getOfferMappingEntries_2' => [ + 'application/json', + ], + 'getOfferMappings_3' => [ + 'application/json', + ], + 'getOfferRecommendations_3' => [ + 'application/json', + ], + 'getOffers_2' => [ + 'application/json', + ], + 'getOrderBusinessBuyerInfo_3' => [ + 'application/json', + ], + 'getOrderBusinessDocumentsInfo_3' => [ + 'application/json', + ], + 'getOrderLabelsData_2' => [ + 'application/json', + ], + 'getOrder_3' => [ + 'application/json', + ], + 'getOrdersStats_3' => [ + 'application/json', + ], + 'getOrders_3' => [ + 'application/json', + ], + 'getPricesByOfferIds_3' => [ + 'application/json', + ], + 'getPrices_3' => [ + 'application/json', + ], + 'getPromoOffers_3' => [ + 'application/json', + ], + 'getPromos_3' => [ + 'application/json', + ], + 'getQualityRatingDetails_2' => [ + 'application/json', + ], + 'getQualityRatings_3' => [ + 'application/json', + ], + 'getReportInfo_3' => [ + 'application/json', + ], + 'getReturnApplication_2' => [ + 'application/json', + ], + 'getReturnPhoto_2' => [ + 'application/json', + ], + 'getReturn_2' => [ + 'application/json', + ], + 'getReturns_2' => [ + 'application/json', + ], + 'getStocks_3' => [ + 'application/json', + ], + 'getSuggestedOfferMappingEntries_2' => [ + 'application/json', + ], + 'getSuggestedOfferMappings_3' => [ + 'application/json', + ], + 'getSuggestedPrices_2' => [ + 'application/json', + ], + 'getWarehouses_2' => [ + 'application/json', + ], + 'provideOrderItemIdentifiers_2' => [ + 'application/json', + ], + 'putBidsForBusiness_3' => [ + 'application/json', + ], + 'putBidsForCampaign_2' => [ + 'application/json', + ], + 'refreshFeed_2' => [ + 'application/json', + ], + 'searchRegionChildren_3' => [ + 'application/json', + ], + 'searchRegionsById_3' => [ + 'application/json', + ], + 'searchRegionsByName_3' => [ + 'application/json', + ], + 'sendFileToChat_3' => [ + 'multipart/form-data', + ], + 'sendMessageToChat_3' => [ + 'application/json', + ], + 'setFeedParams_2' => [ + 'application/json', + ], + 'setOrderBoxLayout_1' => [ + 'application/json', + ], + 'setOrderShipmentBoxes_2' => [ + 'application/json', + ], + 'skipGoodsFeedbacksReaction_3' => [ + 'application/json', + ], + 'updateBusinessPrices_3' => [ + 'application/json', + ], + 'updateCampaignOffers_3' => [ + 'application/json', + ], + 'updateGoodsFeedbackComment_3' => [ + 'application/json', + ], + 'updateOfferContent_3' => [ + 'application/json', + ], + 'updateOfferMappingEntries_2' => [ + 'application/json', + ], + 'updateOfferMappings_3' => [ + 'application/json', + ], + 'updateOrderItems_2' => [ + 'application/json', + ], + 'updateOrderStatus_2' => [ + 'application/json', + ], + 'updateOrderStatuses_2' => [ + 'application/json', + ], + 'updatePrices_3' => [ + 'application/json', + ], + 'updatePromoOffers_3' => [ + 'application/json', + ], + 'updateStocks_2' => [ + 'application/json', + ], + 'verifyOrderEac_0' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addHiddenOffers_3 + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addHiddenOffers_3($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_3'][0]) + { + list($response) = $this->addHiddenOffers_3WithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation addHiddenOffers_3WithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addHiddenOffers_3WithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_3'][0]) + { + $request = $this->addHiddenOffers_3Request($campaign_id, $add_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addHiddenOffers_3Async + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffers_3Async($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_3'][0]) + { + return $this->addHiddenOffers_3AsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addHiddenOffers_3AsyncWithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffers_3AsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->addHiddenOffers_3Request($campaign_id, $add_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addHiddenOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addHiddenOffers_3Request($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling addHiddenOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.addHiddenOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_hidden_offers_request' is set + if ($add_hidden_offers_request === null || (is_array($add_hidden_offers_request) && count($add_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_hidden_offers_request when calling addHiddenOffers_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_hidden_offers_request)); + } else { + $httpBody = $add_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation addOffersToArchive_3 + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addOffersToArchive_3($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_3'][0]) + { + list($response) = $this->addOffersToArchive_3WithHttpInfo($business_id, $add_offers_to_archive_request, $contentType); + return $response; + } + + /** + * Operation addOffersToArchive_3WithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addOffersToArchive_3WithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_3'][0]) + { + $request = $this->addOffersToArchive_3Request($business_id, $add_offers_to_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\AddOffersToArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\AddOffersToArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addOffersToArchive_3Async + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchive_3Async($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_3'][0]) + { + return $this->addOffersToArchive_3AsyncWithHttpInfo($business_id, $add_offers_to_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addOffersToArchive_3AsyncWithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchive_3AsyncWithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + $request = $this->addOffersToArchive_3Request($business_id, $add_offers_to_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addOffersToArchive_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addOffersToArchive_3Request($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling addOffersToArchive_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.addOffersToArchive_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_offers_to_archive_request' is set + if ($add_offers_to_archive_request === null || (is_array($add_offers_to_archive_request) && count($add_offers_to_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_offers_to_archive_request when calling addOffersToArchive_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/archive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_offers_to_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_offers_to_archive_request)); + } else { + $httpBody = $add_offers_to_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation calculateTariffs_3 + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function calculateTariffs_3($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_3'][0]) + { + list($response) = $this->calculateTariffs_3WithHttpInfo($calculate_tariffs_request, $contentType); + return $response; + } + + /** + * Operation calculateTariffs_3WithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function calculateTariffs_3WithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_3'][0]) + { + $request = $this->calculateTariffs_3Request($calculate_tariffs_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CalculateTariffsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CalculateTariffsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation calculateTariffs_3Async + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffs_3Async($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_3'][0]) + { + return $this->calculateTariffs_3AsyncWithHttpInfo($calculate_tariffs_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation calculateTariffs_3AsyncWithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffs_3AsyncWithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + $request = $this->calculateTariffs_3Request($calculate_tariffs_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'calculateTariffs_3' + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function calculateTariffs_3Request($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_3'][0]) + { + + // verify the required parameter 'calculate_tariffs_request' is set + if ($calculate_tariffs_request === null || (is_array($calculate_tariffs_request) && count($calculate_tariffs_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $calculate_tariffs_request when calling calculateTariffs_3' + ); + } + + + $resourcePath = '/tariffs/calculate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($calculate_tariffs_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($calculate_tariffs_request)); + } else { + $httpBody = $calculate_tariffs_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmBusinessPrices_3 + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmBusinessPrices_3($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_3'][0]) + { + list($response) = $this->confirmBusinessPrices_3WithHttpInfo($business_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmBusinessPrices_3WithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmBusinessPrices_3WithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_3'][0]) + { + $request = $this->confirmBusinessPrices_3Request($business_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmBusinessPrices_3Async + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPrices_3Async($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_3'][0]) + { + return $this->confirmBusinessPrices_3AsyncWithHttpInfo($business_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmBusinessPrices_3AsyncWithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPrices_3AsyncWithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmBusinessPrices_3Request($business_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmBusinessPrices_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmBusinessPrices_3Request($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling confirmBusinessPrices_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.confirmBusinessPrices_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmBusinessPrices_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmCampaignPrices_3 + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmCampaignPrices_3($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_3'][0]) + { + list($response) = $this->confirmCampaignPrices_3WithHttpInfo($campaign_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmCampaignPrices_3WithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmCampaignPrices_3WithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_3'][0]) + { + $request = $this->confirmCampaignPrices_3Request($campaign_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmCampaignPrices_3Async + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPrices_3Async($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_3'][0]) + { + return $this->confirmCampaignPrices_3AsyncWithHttpInfo($campaign_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmCampaignPrices_3AsyncWithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPrices_3AsyncWithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmCampaignPrices_3Request($campaign_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmCampaignPrices_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmCampaignPrices_3Request($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling confirmCampaignPrices_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.confirmCampaignPrices_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmCampaignPrices_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation createChat_3 + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function createChat_3($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_3'][0]) + { + list($response) = $this->createChat_3WithHttpInfo($business_id, $create_chat_request, $contentType); + return $response; + } + + /** + * Operation createChat_3WithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function createChat_3WithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_3'][0]) + { + $request = $this->createChat_3Request($business_id, $create_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CreateChatResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CreateChatResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CreateChatResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CreateChatResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createChat_3Async + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChat_3Async($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_3'][0]) + { + return $this->createChat_3AsyncWithHttpInfo($business_id, $create_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createChat_3AsyncWithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChat_3AsyncWithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + $request = $this->createChat_3Request($business_id, $create_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createChat_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createChat_3Request($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling createChat_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.createChat_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'create_chat_request' is set + if ($create_chat_request === null || (is_array($create_chat_request) && count($create_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $create_chat_request when calling createChat_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/new'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($create_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($create_chat_request)); + } else { + $httpBody = $create_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteCampaignOffers_3 + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteCampaignOffers_3($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_3'][0]) + { + list($response) = $this->deleteCampaignOffers_3WithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteCampaignOffers_3WithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteCampaignOffers_3WithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_3'][0]) + { + $request = $this->deleteCampaignOffers_3Request($campaign_id, $delete_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteCampaignOffers_3Async + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffers_3Async($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_3'][0]) + { + return $this->deleteCampaignOffers_3AsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteCampaignOffers_3AsyncWithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffers_3AsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + $request = $this->deleteCampaignOffers_3Request($campaign_id, $delete_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteCampaignOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteCampaignOffers_3Request($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteCampaignOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.deleteCampaignOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_campaign_offers_request' is set + if ($delete_campaign_offers_request === null || (is_array($delete_campaign_offers_request) && count($delete_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_campaign_offers_request when calling deleteCampaignOffers_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_campaign_offers_request)); + } else { + $httpBody = $delete_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteGoodsFeedbackComment_3 + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteGoodsFeedbackComment_3($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_3'][0]) + { + list($response) = $this->deleteGoodsFeedbackComment_3WithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation deleteGoodsFeedbackComment_3WithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteGoodsFeedbackComment_3WithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_3'][0]) + { + $request = $this->deleteGoodsFeedbackComment_3Request($business_id, $delete_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteGoodsFeedbackComment_3Async + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackComment_3Async($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_3'][0]) + { + return $this->deleteGoodsFeedbackComment_3AsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteGoodsFeedbackComment_3AsyncWithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackComment_3AsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteGoodsFeedbackComment_3Request($business_id, $delete_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteGoodsFeedbackComment_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteGoodsFeedbackComment_3Request($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteGoodsFeedbackComment_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.deleteGoodsFeedbackComment_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_goods_feedback_comment_request' is set + if ($delete_goods_feedback_comment_request === null || (is_array($delete_goods_feedback_comment_request) && count($delete_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_goods_feedback_comment_request when calling deleteGoodsFeedbackComment_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_goods_feedback_comment_request)); + } else { + $httpBody = $delete_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteHiddenOffers_3 + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteHiddenOffers_3($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_3'][0]) + { + list($response) = $this->deleteHiddenOffers_3WithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteHiddenOffers_3WithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteHiddenOffers_3WithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_3'][0]) + { + $request = $this->deleteHiddenOffers_3Request($campaign_id, $delete_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteHiddenOffers_3Async + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffers_3Async($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_3'][0]) + { + return $this->deleteHiddenOffers_3AsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteHiddenOffers_3AsyncWithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffers_3AsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteHiddenOffers_3Request($campaign_id, $delete_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteHiddenOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteHiddenOffers_3Request($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteHiddenOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.deleteHiddenOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_hidden_offers_request' is set + if ($delete_hidden_offers_request === null || (is_array($delete_hidden_offers_request) && count($delete_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_hidden_offers_request when calling deleteHiddenOffers_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_hidden_offers_request)); + } else { + $httpBody = $delete_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffersFromArchive_3 + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffersFromArchive_3($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_3'][0]) + { + list($response) = $this->deleteOffersFromArchive_3WithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType); + return $response; + } + + /** + * Operation deleteOffersFromArchive_3WithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffersFromArchive_3WithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_3'][0]) + { + $request = $this->deleteOffersFromArchive_3Request($business_id, $delete_offers_from_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffersFromArchive_3Async + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchive_3Async($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_3'][0]) + { + return $this->deleteOffersFromArchive_3AsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffersFromArchive_3AsyncWithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchive_3AsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + $request = $this->deleteOffersFromArchive_3Request($business_id, $delete_offers_from_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffersFromArchive_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffersFromArchive_3Request($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffersFromArchive_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.deleteOffersFromArchive_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_from_archive_request' is set + if ($delete_offers_from_archive_request === null || (is_array($delete_offers_from_archive_request) && count($delete_offers_from_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_from_archive_request when calling deleteOffersFromArchive_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/unarchive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_from_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_from_archive_request)); + } else { + $httpBody = $delete_offers_from_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffers_3 + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffers_3($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_3'][0]) + { + list($response) = $this->deleteOffers_3WithHttpInfo($business_id, $delete_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteOffers_3WithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffers_3WithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_3'][0]) + { + $request = $this->deleteOffers_3Request($business_id, $delete_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffers_3Async + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffers_3Async($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_3'][0]) + { + return $this->deleteOffers_3AsyncWithHttpInfo($business_id, $delete_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffers_3AsyncWithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffers_3AsyncWithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + $request = $this->deleteOffers_3Request($business_id, $delete_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffers_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffers_3Request($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffers_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.deleteOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_request' is set + if ($delete_offers_request === null || (is_array($delete_offers_request) && count($delete_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_request when calling deleteOffers_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_request)); + } else { + $httpBody = $delete_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deletePromoOffers_3 + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deletePromoOffers_3($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_3'][0]) + { + list($response) = $this->deletePromoOffers_3WithHttpInfo($business_id, $delete_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation deletePromoOffers_3WithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deletePromoOffers_3WithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_3'][0]) + { + $request = $this->deletePromoOffers_3Request($business_id, $delete_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeletePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeletePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deletePromoOffers_3Async + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffers_3Async($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_3'][0]) + { + return $this->deletePromoOffers_3AsyncWithHttpInfo($business_id, $delete_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deletePromoOffers_3AsyncWithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffers_3AsyncWithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + $request = $this->deletePromoOffers_3Request($business_id, $delete_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePromoOffers_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deletePromoOffers_3Request($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deletePromoOffers_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.deletePromoOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_promo_offers_request' is set + if ($delete_promo_offers_request === null || (is_array($delete_promo_offers_request) && count($delete_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_promo_offers_request when calling deletePromoOffers_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_promo_offers_request)); + } else { + $httpBody = $delete_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateBoostConsolidatedReport_3 + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateBoostConsolidatedReport_3($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_3'][0]) + { + list($response) = $this->generateBoostConsolidatedReport_3WithHttpInfo($generate_boost_consolidated_request, $format, $contentType); + return $response; + } + + /** + * Operation generateBoostConsolidatedReport_3WithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateBoostConsolidatedReport_3WithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_3'][0]) + { + $request = $this->generateBoostConsolidatedReport_3Request($generate_boost_consolidated_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateBoostConsolidatedReport_3Async + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReport_3Async($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_3'][0]) + { + return $this->generateBoostConsolidatedReport_3AsyncWithHttpInfo($generate_boost_consolidated_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateBoostConsolidatedReport_3AsyncWithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReport_3AsyncWithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateBoostConsolidatedReport_3Request($generate_boost_consolidated_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateBoostConsolidatedReport_3' + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateBoostConsolidatedReport_3Request($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_3'][0]) + { + + // verify the required parameter 'generate_boost_consolidated_request' is set + if ($generate_boost_consolidated_request === null || (is_array($generate_boost_consolidated_request) && count($generate_boost_consolidated_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_boost_consolidated_request when calling generateBoostConsolidatedReport_3' + ); + } + + + + $resourcePath = '/reports/boost-consolidated/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_boost_consolidated_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_boost_consolidated_request)); + } else { + $httpBody = $generate_boost_consolidated_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateCompetitorsPositionReport_3 + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateCompetitorsPositionReport_3($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_3'][0]) + { + list($response) = $this->generateCompetitorsPositionReport_3WithHttpInfo($generate_competitors_position_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateCompetitorsPositionReport_3WithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateCompetitorsPositionReport_3WithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_3'][0]) + { + $request = $this->generateCompetitorsPositionReport_3Request($generate_competitors_position_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateCompetitorsPositionReport_3Async + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReport_3Async($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_3'][0]) + { + return $this->generateCompetitorsPositionReport_3AsyncWithHttpInfo($generate_competitors_position_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateCompetitorsPositionReport_3AsyncWithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReport_3AsyncWithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateCompetitorsPositionReport_3Request($generate_competitors_position_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateCompetitorsPositionReport_3' + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateCompetitorsPositionReport_3Request($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_3'][0]) + { + + // verify the required parameter 'generate_competitors_position_report_request' is set + if ($generate_competitors_position_report_request === null || (is_array($generate_competitors_position_report_request) && count($generate_competitors_position_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_competitors_position_report_request when calling generateCompetitorsPositionReport_3' + ); + } + + + + $resourcePath = '/reports/competitors-position/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_competitors_position_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_competitors_position_report_request)); + } else { + $httpBody = $generate_competitors_position_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsFeedbackReport_3 + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsFeedbackReport_3($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_3'][0]) + { + list($response) = $this->generateGoodsFeedbackReport_3WithHttpInfo($generate_goods_feedback_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsFeedbackReport_3WithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsFeedbackReport_3WithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_3'][0]) + { + $request = $this->generateGoodsFeedbackReport_3Request($generate_goods_feedback_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsFeedbackReport_3Async + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReport_3Async($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_3'][0]) + { + return $this->generateGoodsFeedbackReport_3AsyncWithHttpInfo($generate_goods_feedback_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsFeedbackReport_3AsyncWithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReport_3AsyncWithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsFeedbackReport_3Request($generate_goods_feedback_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsFeedbackReport_3' + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsFeedbackReport_3Request($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_3'][0]) + { + + // verify the required parameter 'generate_goods_feedback_request' is set + if ($generate_goods_feedback_request === null || (is_array($generate_goods_feedback_request) && count($generate_goods_feedback_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_feedback_request when calling generateGoodsFeedbackReport_3' + ); + } + + + + $resourcePath = '/reports/goods-feedback/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_feedback_request)); + } else { + $httpBody = $generate_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsRealizationReport_2 + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsRealizationReport_2($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_2'][0]) + { + list($response) = $this->generateGoodsRealizationReport_2WithHttpInfo($generate_goods_realization_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsRealizationReport_2WithHttpInfo + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsRealizationReport_2WithHttpInfo($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_2'][0]) + { + $request = $this->generateGoodsRealizationReport_2Request($generate_goods_realization_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsRealizationReport_2Async + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsRealizationReport_2Async($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_2'][0]) + { + return $this->generateGoodsRealizationReport_2AsyncWithHttpInfo($generate_goods_realization_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsRealizationReport_2AsyncWithHttpInfo + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsRealizationReport_2AsyncWithHttpInfo($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsRealizationReport_2Request($generate_goods_realization_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsRealizationReport_2' + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsRealizationReport_2Request($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_2'][0]) + { + + // verify the required parameter 'generate_goods_realization_report_request' is set + if ($generate_goods_realization_report_request === null || (is_array($generate_goods_realization_report_request) && count($generate_goods_realization_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_realization_report_request when calling generateGoodsRealizationReport_2' + ); + } + + + + $resourcePath = '/reports/goods-realization/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_realization_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_realization_report_request)); + } else { + $httpBody = $generate_goods_realization_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateMassOrderLabelsReport_2 + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateMassOrderLabelsReport_2($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_2'][0]) + { + list($response) = $this->generateMassOrderLabelsReport_2WithHttpInfo($generate_mass_order_labels_request, $format, $contentType); + return $response; + } + + /** + * Operation generateMassOrderLabelsReport_2WithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateMassOrderLabelsReport_2WithHttpInfo($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_2'][0]) + { + $request = $this->generateMassOrderLabelsReport_2Request($generate_mass_order_labels_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateMassOrderLabelsReport_2Async + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateMassOrderLabelsReport_2Async($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_2'][0]) + { + return $this->generateMassOrderLabelsReport_2AsyncWithHttpInfo($generate_mass_order_labels_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateMassOrderLabelsReport_2AsyncWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateMassOrderLabelsReport_2AsyncWithHttpInfo($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateMassOrderLabelsReport_2Request($generate_mass_order_labels_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateMassOrderLabelsReport_2' + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateMassOrderLabelsReport_2Request($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_2'][0]) + { + + // verify the required parameter 'generate_mass_order_labels_request' is set + if ($generate_mass_order_labels_request === null || (is_array($generate_mass_order_labels_request) && count($generate_mass_order_labels_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_mass_order_labels_request when calling generateMassOrderLabelsReport_2' + ); + } + + + + $resourcePath = '/reports/documents/labels/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_mass_order_labels_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_mass_order_labels_request)); + } else { + $httpBody = $generate_mass_order_labels_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateOrderLabel_2 + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateOrderLabel_2($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_2'][0]) + { + list($response) = $this->generateOrderLabel_2WithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + return $response; + } + + /** + * Operation generateOrderLabel_2WithHttpInfo + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateOrderLabel_2WithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_2'][0]) + { + $request = $this->generateOrderLabel_2Request($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateOrderLabel_2Async + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabel_2Async($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_2'][0]) + { + return $this->generateOrderLabel_2AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateOrderLabel_2AsyncWithHttpInfo + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabel_2AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_2'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->generateOrderLabel_2Request($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateOrderLabel_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateOrderLabel_2Request($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling generateOrderLabel_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.generateOrderLabel_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling generateOrderLabel_2' + ); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling generateOrderLabel_2' + ); + } + + // verify the required parameter 'box_id' is set + if ($box_id === null || (is_array($box_id) && count($box_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $box_id when calling generateOrderLabel_2' + ); + } + + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes/{boxId}/label'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + // path params + if ($box_id !== null) { + $resourcePath = str_replace( + '{' . 'boxId' . '}', + ObjectSerializer::toPathValue($box_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateOrderLabels_2 + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateOrderLabels_2($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_2'][0]) + { + list($response) = $this->generateOrderLabels_2WithHttpInfo($campaign_id, $order_id, $format, $contentType); + return $response; + } + + /** + * Operation generateOrderLabels_2WithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateOrderLabels_2WithHttpInfo($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_2'][0]) + { + $request = $this->generateOrderLabels_2Request($campaign_id, $order_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateOrderLabels_2Async + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabels_2Async($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_2'][0]) + { + return $this->generateOrderLabels_2AsyncWithHttpInfo($campaign_id, $order_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateOrderLabels_2AsyncWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabels_2AsyncWithHttpInfo($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_2'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->generateOrderLabels_2Request($campaign_id, $order_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateOrderLabels_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateOrderLabels_2Request($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling generateOrderLabels_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.generateOrderLabels_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling generateOrderLabels_2' + ); + } + + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/labels'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generatePricesReport_3 + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generatePricesReport_3($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_3'][0]) + { + list($response) = $this->generatePricesReport_3WithHttpInfo($generate_prices_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generatePricesReport_3WithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generatePricesReport_3WithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_3'][0]) + { + $request = $this->generatePricesReport_3Request($generate_prices_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generatePricesReport_3Async + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReport_3Async($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_3'][0]) + { + return $this->generatePricesReport_3AsyncWithHttpInfo($generate_prices_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generatePricesReport_3AsyncWithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReport_3AsyncWithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generatePricesReport_3Request($generate_prices_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generatePricesReport_3' + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generatePricesReport_3Request($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_3'][0]) + { + + // verify the required parameter 'generate_prices_report_request' is set + if ($generate_prices_report_request === null || (is_array($generate_prices_report_request) && count($generate_prices_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_prices_report_request when calling generatePricesReport_3' + ); + } + + + + $resourcePath = '/reports/prices/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_prices_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_prices_report_request)); + } else { + $httpBody = $generate_prices_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShelfsStatisticsReport_3 + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShelfsStatisticsReport_3($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_3'][0]) + { + list($response) = $this->generateShelfsStatisticsReport_3WithHttpInfo($generate_shelfs_statistics_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShelfsStatisticsReport_3WithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShelfsStatisticsReport_3WithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_3'][0]) + { + $request = $this->generateShelfsStatisticsReport_3Request($generate_shelfs_statistics_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShelfsStatisticsReport_3Async + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReport_3Async($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_3'][0]) + { + return $this->generateShelfsStatisticsReport_3AsyncWithHttpInfo($generate_shelfs_statistics_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShelfsStatisticsReport_3AsyncWithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReport_3AsyncWithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShelfsStatisticsReport_3Request($generate_shelfs_statistics_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShelfsStatisticsReport_3' + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShelfsStatisticsReport_3Request($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_3'][0]) + { + + // verify the required parameter 'generate_shelfs_statistics_request' is set + if ($generate_shelfs_statistics_request === null || (is_array($generate_shelfs_statistics_request) && count($generate_shelfs_statistics_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shelfs_statistics_request when calling generateShelfsStatisticsReport_3' + ); + } + + + + $resourcePath = '/reports/shelf-statistics/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shelfs_statistics_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shelfs_statistics_request)); + } else { + $httpBody = $generate_shelfs_statistics_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShowsSalesReport_3 + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShowsSalesReport_3($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_3'][0]) + { + list($response) = $this->generateShowsSalesReport_3WithHttpInfo($generate_shows_sales_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShowsSalesReport_3WithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShowsSalesReport_3WithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_3'][0]) + { + $request = $this->generateShowsSalesReport_3Request($generate_shows_sales_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShowsSalesReport_3Async + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReport_3Async($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_3'][0]) + { + return $this->generateShowsSalesReport_3AsyncWithHttpInfo($generate_shows_sales_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShowsSalesReport_3AsyncWithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReport_3AsyncWithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShowsSalesReport_3Request($generate_shows_sales_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShowsSalesReport_3' + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShowsSalesReport_3Request($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_3'][0]) + { + + // verify the required parameter 'generate_shows_sales_report_request' is set + if ($generate_shows_sales_report_request === null || (is_array($generate_shows_sales_report_request) && count($generate_shows_sales_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shows_sales_report_request when calling generateShowsSalesReport_3' + ); + } + + + + $resourcePath = '/reports/shows-sales/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shows_sales_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shows_sales_report_request)); + } else { + $httpBody = $generate_shows_sales_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateStocksOnWarehousesReport_3 + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateStocksOnWarehousesReport_3($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_3'][0]) + { + list($response) = $this->generateStocksOnWarehousesReport_3WithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateStocksOnWarehousesReport_3WithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateStocksOnWarehousesReport_3WithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_3'][0]) + { + $request = $this->generateStocksOnWarehousesReport_3Request($generate_stocks_on_warehouses_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateStocksOnWarehousesReport_3Async + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReport_3Async($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_3'][0]) + { + return $this->generateStocksOnWarehousesReport_3AsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateStocksOnWarehousesReport_3AsyncWithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReport_3AsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateStocksOnWarehousesReport_3Request($generate_stocks_on_warehouses_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateStocksOnWarehousesReport_3' + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateStocksOnWarehousesReport_3Request($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_3'][0]) + { + + // verify the required parameter 'generate_stocks_on_warehouses_report_request' is set + if ($generate_stocks_on_warehouses_report_request === null || (is_array($generate_stocks_on_warehouses_report_request) && count($generate_stocks_on_warehouses_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_stocks_on_warehouses_report_request when calling generateStocksOnWarehousesReport_3' + ); + } + + + + $resourcePath = '/reports/stocks-on-warehouses/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_stocks_on_warehouses_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_stocks_on_warehouses_report_request)); + } else { + $httpBody = $generate_stocks_on_warehouses_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport_3 + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedMarketplaceServicesReport_3($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_3'][0]) + { + list($response) = $this->generateUnitedMarketplaceServicesReport_3WithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedMarketplaceServicesReport_3WithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedMarketplaceServicesReport_3WithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_3'][0]) + { + $request = $this->generateUnitedMarketplaceServicesReport_3Request($generate_united_marketplace_services_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedMarketplaceServicesReport_3Async + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReport_3Async($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_3'][0]) + { + return $this->generateUnitedMarketplaceServicesReport_3AsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport_3AsyncWithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReport_3AsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedMarketplaceServicesReport_3Request($generate_united_marketplace_services_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedMarketplaceServicesReport_3' + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedMarketplaceServicesReport_3Request($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_3'][0]) + { + + // verify the required parameter 'generate_united_marketplace_services_report_request' is set + if ($generate_united_marketplace_services_report_request === null || (is_array($generate_united_marketplace_services_report_request) && count($generate_united_marketplace_services_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_marketplace_services_report_request when calling generateUnitedMarketplaceServicesReport_3' + ); + } + + + + $resourcePath = '/reports/united-marketplace-services/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_marketplace_services_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_marketplace_services_report_request)); + } else { + $httpBody = $generate_united_marketplace_services_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedNettingReport_3 + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedNettingReport_3($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_3'][0]) + { + list($response) = $this->generateUnitedNettingReport_3WithHttpInfo($generate_united_netting_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedNettingReport_3WithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedNettingReport_3WithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_3'][0]) + { + $request = $this->generateUnitedNettingReport_3Request($generate_united_netting_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedNettingReport_3Async + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReport_3Async($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_3'][0]) + { + return $this->generateUnitedNettingReport_3AsyncWithHttpInfo($generate_united_netting_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedNettingReport_3AsyncWithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReport_3AsyncWithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedNettingReport_3Request($generate_united_netting_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedNettingReport_3' + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedNettingReport_3Request($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_3'][0]) + { + + // verify the required parameter 'generate_united_netting_report_request' is set + if ($generate_united_netting_report_request === null || (is_array($generate_united_netting_report_request) && count($generate_united_netting_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_netting_report_request when calling generateUnitedNettingReport_3' + ); + } + + + + $resourcePath = '/reports/united-netting/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_netting_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_netting_report_request)); + } else { + $httpBody = $generate_united_netting_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedOrdersReport_3 + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedOrdersReport_3($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_3'][0]) + { + list($response) = $this->generateUnitedOrdersReport_3WithHttpInfo($generate_united_orders_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedOrdersReport_3WithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedOrdersReport_3WithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_3'][0]) + { + $request = $this->generateUnitedOrdersReport_3Request($generate_united_orders_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedOrdersReport_3Async + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReport_3Async($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_3'][0]) + { + return $this->generateUnitedOrdersReport_3AsyncWithHttpInfo($generate_united_orders_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedOrdersReport_3AsyncWithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReport_3AsyncWithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedOrdersReport_3Request($generate_united_orders_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedOrdersReport_3' + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedOrdersReport_3Request($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_3'][0]) + { + + // verify the required parameter 'generate_united_orders_request' is set + if ($generate_united_orders_request === null || (is_array($generate_united_orders_request) && count($generate_united_orders_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_orders_request when calling generateUnitedOrdersReport_3' + ); + } + + + + $resourcePath = '/reports/united-orders/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_orders_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_orders_request)); + } else { + $httpBody = $generate_united_orders_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getAllOffers_2 + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getAllOffers_2($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_2'][0]) + { + list($response) = $this->getAllOffers_2WithHttpInfo($campaign_id, $feed_id, $chunk, $contentType); + return $response; + } + + /** + * Operation getAllOffers_2WithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getAllOffers_2WithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_2'][0]) + { + $request = $this->getAllOffers_2Request($campaign_id, $feed_id, $chunk, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetAllOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetAllOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetAllOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetAllOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getAllOffers_2Async + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffers_2Async($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_2'][0]) + { + return $this->getAllOffers_2AsyncWithHttpInfo($campaign_id, $feed_id, $chunk, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getAllOffers_2AsyncWithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffers_2AsyncWithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + $request = $this->getAllOffers_2Request($campaign_id, $feed_id, $chunk, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getAllOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getAllOffers_2Request($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getAllOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getAllOffers_2, must be bigger than or equal to 1.'); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers/all'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chunk, + 'chunk', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsInfoForBusiness_3 + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsInfoForBusiness_3($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_3'][0]) + { + list($response) = $this->getBidsInfoForBusiness_3WithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + return $response; + } + + /** + * Operation getBidsInfoForBusiness_3WithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsInfoForBusiness_3WithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_3'][0]) + { + $request = $this->getBidsInfoForBusiness_3Request($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsInfoForBusiness_3Async + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusiness_3Async($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_3'][0]) + { + return $this->getBidsInfoForBusiness_3AsyncWithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsInfoForBusiness_3AsyncWithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusiness_3AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + $request = $this->getBidsInfoForBusiness_3Request($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsInfoForBusiness_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsInfoForBusiness_3Request($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsInfoForBusiness_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getBidsInfoForBusiness_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/bids/info'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_info_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_info_request)); + } else { + $httpBody = $get_bids_info_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsRecommendations_3 + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsRecommendations_3($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_3'][0]) + { + list($response) = $this->getBidsRecommendations_3WithHttpInfo($business_id, $get_bids_recommendations_request, $contentType); + return $response; + } + + /** + * Operation getBidsRecommendations_3WithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsRecommendations_3WithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_3'][0]) + { + $request = $this->getBidsRecommendations_3Request($business_id, $get_bids_recommendations_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsRecommendations_3Async + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendations_3Async($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_3'][0]) + { + return $this->getBidsRecommendations_3AsyncWithHttpInfo($business_id, $get_bids_recommendations_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsRecommendations_3AsyncWithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendations_3AsyncWithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + $request = $this->getBidsRecommendations_3Request($business_id, $get_bids_recommendations_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsRecommendations_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsRecommendations_3Request($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsRecommendations_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getBidsRecommendations_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_bids_recommendations_request' is set + if ($get_bids_recommendations_request === null || (is_array($get_bids_recommendations_request) && count($get_bids_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_bids_recommendations_request when calling getBidsRecommendations_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_recommendations_request)); + } else { + $httpBody = $get_bids_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessQuarantineOffers_3 + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessQuarantineOffers_3($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_3'][0]) + { + list($response) = $this->getBusinessQuarantineOffers_3WithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getBusinessQuarantineOffers_3WithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessQuarantineOffers_3WithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_3'][0]) + { + $request = $this->getBusinessQuarantineOffers_3Request($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessQuarantineOffers_3Async + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffers_3Async($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_3'][0]) + { + return $this->getBusinessQuarantineOffers_3AsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessQuarantineOffers_3AsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffers_3AsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getBusinessQuarantineOffers_3Request($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessQuarantineOffers_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessQuarantineOffers_3Request($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessQuarantineOffers_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getBusinessQuarantineOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getBusinessQuarantineOffers_3' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessSettings_3 + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessSettings_3($business_id, string $contentType = self::contentTypes['getBusinessSettings_3'][0]) + { + list($response) = $this->getBusinessSettings_3WithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getBusinessSettings_3WithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessSettings_3WithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings_3'][0]) + { + $request = $this->getBusinessSettings_3Request($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessSettings_3Async + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettings_3Async($business_id, string $contentType = self::contentTypes['getBusinessSettings_3'][0]) + { + return $this->getBusinessSettings_3AsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessSettings_3AsyncWithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettings_3AsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + $request = $this->getBusinessSettings_3Request($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessSettings_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessSettings_3Request($business_id, string $contentType = self::contentTypes['getBusinessSettings_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessSettings_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getBusinessSettings_3, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignLogins_1 + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignLogins_1($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_1'][0]) + { + list($response) = $this->getCampaignLogins_1WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignLogins_1WithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignLogins_1WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_1'][0]) + { + $request = $this->getCampaignLogins_1Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignLoginsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignLoginsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignLogins_1Async + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLogins_1Async($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_1'][0]) + { + return $this->getCampaignLogins_1AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignLogins_1AsyncWithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLogins_1AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + $request = $this->getCampaignLogins_1Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignLogins_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignLogins_1Request($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignLogins_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getCampaignLogins_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/logins'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignOffers_3 + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignOffers_3($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_3'][0]) + { + list($response) = $this->getCampaignOffers_3WithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignOffers_3WithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignOffers_3WithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_3'][0]) + { + $request = $this->getCampaignOffers_3Request($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignOffers_3Async + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffers_3Async($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_3'][0]) + { + return $this->getCampaignOffers_3AsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignOffers_3AsyncWithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffers_3AsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + $request = $this->getCampaignOffers_3Request($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignOffers_3Request($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getCampaignOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_campaign_offers_request' is set + if ($get_campaign_offers_request === null || (is_array($get_campaign_offers_request) && count($get_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_campaign_offers_request when calling getCampaignOffers_3' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_campaign_offers_request)); + } else { + $httpBody = $get_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignQuarantineOffers_3 + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignQuarantineOffers_3($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_3'][0]) + { + list($response) = $this->getCampaignQuarantineOffers_3WithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignQuarantineOffers_3WithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignQuarantineOffers_3WithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_3'][0]) + { + $request = $this->getCampaignQuarantineOffers_3Request($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignQuarantineOffers_3Async + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffers_3Async($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_3'][0]) + { + return $this->getCampaignQuarantineOffers_3AsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignQuarantineOffers_3AsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffers_3AsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getCampaignQuarantineOffers_3Request($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignQuarantineOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignQuarantineOffers_3Request($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignQuarantineOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getCampaignQuarantineOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getCampaignQuarantineOffers_3' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignRegion_3 + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getCampaignRegion_3($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_3'][0]) + { + list($response) = $this->getCampaignRegion_3WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignRegion_3WithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getCampaignRegion_3WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_3'][0]) + { + $request = $this->getCampaignRegion_3Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignRegionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignRegionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignRegion_3Async + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegion_3Async($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_3'][0]) + { + return $this->getCampaignRegion_3AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignRegion_3AsyncWithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegion_3AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + $request = $this->getCampaignRegion_3Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignRegion_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getCampaignRegion_3Request($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignRegion_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getCampaignRegion_3, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/region'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignSettings_2 + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignSettings_2($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_2'][0]) + { + list($response) = $this->getCampaignSettings_2WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignSettings_2WithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignSettings_2WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_2'][0]) + { + $request = $this->getCampaignSettings_2Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignSettings_2Async + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettings_2Async($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_2'][0]) + { + return $this->getCampaignSettings_2AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignSettings_2AsyncWithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettings_2AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + $request = $this->getCampaignSettings_2Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignSettings_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignSettings_2Request($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignSettings_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getCampaignSettings_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaign_1 + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaign_1($campaign_id, string $contentType = self::contentTypes['getCampaign_1'][0]) + { + list($response) = $this->getCampaign_1WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaign_1WithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaign_1WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign_1'][0]) + { + $request = $this->getCampaign_1Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaign_1Async + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaign_1Async($campaign_id, string $contentType = self::contentTypes['getCampaign_1'][0]) + { + return $this->getCampaign_1AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaign_1AsyncWithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaign_1AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + $request = $this->getCampaign_1Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaign_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaign_1Request($campaign_id, string $contentType = self::contentTypes['getCampaign_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaign_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getCampaign_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignsByLogin_1 + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignsByLogin_1($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_1'][0]) + { + list($response) = $this->getCampaignsByLogin_1WithHttpInfo($login, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaignsByLogin_1WithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignsByLogin_1WithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_1'][0]) + { + $request = $this->getCampaignsByLogin_1Request($login, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignsByLogin_1Async + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLogin_1Async($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_1'][0]) + { + return $this->getCampaignsByLogin_1AsyncWithHttpInfo($login, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignsByLogin_1AsyncWithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLogin_1AsyncWithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaignsByLogin_1Request($login, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignsByLogin_1' + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignsByLogin_1Request($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_1'][0]) + { + + // verify the required parameter 'login' is set + if ($login === null || (is_array($login) && count($login) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $login when calling getCampaignsByLogin_1' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling ExpressApi.getCampaignsByLogin_1, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/by_login/{login}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($login !== null) { + $resourcePath = str_replace( + '{' . 'login' . '}', + ObjectSerializer::toPathValue($login), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaigns_1 + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaigns_1($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_1'][0]) + { + list($response) = $this->getCampaigns_1WithHttpInfo($page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaigns_1WithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaigns_1WithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_1'][0]) + { + $request = $this->getCampaigns_1Request($page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaigns_1Async + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaigns_1Async($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_1'][0]) + { + return $this->getCampaigns_1AsyncWithHttpInfo($page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaigns_1AsyncWithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaigns_1AsyncWithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaigns_1Request($page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaigns_1' + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaigns_1Request($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_1'][0]) + { + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling ExpressApi.getCampaigns_1, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesMaxSaleQuantum_3 + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesMaxSaleQuantum_3($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_3'][0]) + { + list($response) = $this->getCategoriesMaxSaleQuantum_3WithHttpInfo($get_categories_max_sale_quantum_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesMaxSaleQuantum_3WithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesMaxSaleQuantum_3WithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_3'][0]) + { + $request = $this->getCategoriesMaxSaleQuantum_3Request($get_categories_max_sale_quantum_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesMaxSaleQuantum_3Async + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantum_3Async($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_3'][0]) + { + return $this->getCategoriesMaxSaleQuantum_3AsyncWithHttpInfo($get_categories_max_sale_quantum_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesMaxSaleQuantum_3AsyncWithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantum_3AsyncWithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + $request = $this->getCategoriesMaxSaleQuantum_3Request($get_categories_max_sale_quantum_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesMaxSaleQuantum_3' + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesMaxSaleQuantum_3Request($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_3'][0]) + { + + // verify the required parameter 'get_categories_max_sale_quantum_request' is set + if ($get_categories_max_sale_quantum_request === null || (is_array($get_categories_max_sale_quantum_request) && count($get_categories_max_sale_quantum_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_categories_max_sale_quantum_request when calling getCategoriesMaxSaleQuantum_3' + ); + } + + + $resourcePath = '/categories/max-sale-quantum'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_max_sale_quantum_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_max_sale_quantum_request)); + } else { + $httpBody = $get_categories_max_sale_quantum_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesTree_3 + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesTree_3($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_3'][0]) + { + list($response) = $this->getCategoriesTree_3WithHttpInfo($get_categories_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesTree_3WithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesTree_3WithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_3'][0]) + { + $request = $this->getCategoriesTree_3Request($get_categories_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesTree_3Async + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTree_3Async($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_3'][0]) + { + return $this->getCategoriesTree_3AsyncWithHttpInfo($get_categories_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesTree_3AsyncWithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTree_3AsyncWithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + $request = $this->getCategoriesTree_3Request($get_categories_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesTree_3' + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesTree_3Request($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_3'][0]) + { + + + + $resourcePath = '/categories/tree'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_request)); + } else { + $httpBody = $get_categories_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoryContentParameters_3 + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoryContentParameters_3($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_3'][0]) + { + list($response) = $this->getCategoryContentParameters_3WithHttpInfo($category_id, $contentType); + return $response; + } + + /** + * Operation getCategoryContentParameters_3WithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoryContentParameters_3WithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_3'][0]) + { + $request = $this->getCategoryContentParameters_3Request($category_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoryContentParameters_3Async + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParameters_3Async($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_3'][0]) + { + return $this->getCategoryContentParameters_3AsyncWithHttpInfo($category_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoryContentParameters_3AsyncWithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParameters_3AsyncWithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + $request = $this->getCategoryContentParameters_3Request($category_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoryContentParameters_3' + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoryContentParameters_3Request($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_3'][0]) + { + + // verify the required parameter 'category_id' is set + if ($category_id === null || (is_array($category_id) && count($category_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $category_id when calling getCategoryContentParameters_3' + ); + } + if ($category_id < 1) { + throw new \InvalidArgumentException('invalid value for "$category_id" when calling ExpressApi.getCategoryContentParameters_3, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/category/{categoryId}/parameters'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($category_id !== null) { + $resourcePath = str_replace( + '{' . 'categoryId' . '}', + ObjectSerializer::toPathValue($category_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChatHistory_3 + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChatHistory_3($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_3'][0]) + { + list($response) = $this->getChatHistory_3WithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChatHistory_3WithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChatHistory_3WithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_3'][0]) + { + $request = $this->getChatHistory_3Request($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatHistoryResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatHistoryResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChatHistory_3Async + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistory_3Async($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_3'][0]) + { + return $this->getChatHistory_3AsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChatHistory_3AsyncWithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistory_3AsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + $request = $this->getChatHistory_3Request($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChatHistory_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChatHistory_3Request($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChatHistory_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getChatHistory_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling getChatHistory_3' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling ExpressApi.getChatHistory_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chat_history_request' is set + if ($get_chat_history_request === null || (is_array($get_chat_history_request) && count($get_chat_history_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chat_history_request when calling getChatHistory_3' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chat_history_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chat_history_request)); + } else { + $httpBody = $get_chat_history_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChats_3 + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChats_3($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_3'][0]) + { + list($response) = $this->getChats_3WithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChats_3WithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChats_3WithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_3'][0]) + { + $request = $this->getChats_3Request($business_id, $get_chats_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChats_3Async + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChats_3Async($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_3'][0]) + { + return $this->getChats_3AsyncWithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChats_3AsyncWithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChats_3AsyncWithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + $request = $this->getChats_3Request($business_id, $get_chats_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChats_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChats_3Request($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChats_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getChats_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chats_request' is set + if ($get_chats_request === null || (is_array($get_chats_request) && count($get_chats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chats_request when calling getChats_3' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chats_request)); + } else { + $httpBody = $get_chats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getDeliveryServices_2 + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetDeliveryServicesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getDeliveryServices_2(string $contentType = self::contentTypes['getDeliveryServices_2'][0]) + { + list($response) = $this->getDeliveryServices_2WithHttpInfo($contentType); + return $response; + } + + /** + * Operation getDeliveryServices_2WithHttpInfo + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetDeliveryServicesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getDeliveryServices_2WithHttpInfo(string $contentType = self::contentTypes['getDeliveryServices_2'][0]) + { + $request = $this->getDeliveryServices_2Request($contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetDeliveryServicesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetDeliveryServicesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetDeliveryServicesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetDeliveryServicesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetDeliveryServicesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getDeliveryServices_2Async + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDeliveryServices_2Async(string $contentType = self::contentTypes['getDeliveryServices_2'][0]) + { + return $this->getDeliveryServices_2AsyncWithHttpInfo($contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getDeliveryServices_2AsyncWithHttpInfo + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDeliveryServices_2AsyncWithHttpInfo(string $contentType = self::contentTypes['getDeliveryServices_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetDeliveryServicesResponse'; + $request = $this->getDeliveryServices_2Request($contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getDeliveryServices_2' + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getDeliveryServices_2Request(string $contentType = self::contentTypes['getDeliveryServices_2'][0]) + { + + + $resourcePath = '/delivery/services'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedIndexLogs_2 + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedIndexLogs_2($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_2'][0]) + { + list($response) = $this->getFeedIndexLogs_2WithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + return $response; + } + + /** + * Operation getFeedIndexLogs_2WithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedIndexLogs_2WithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_2'][0]) + { + $request = $this->getFeedIndexLogs_2Request($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedIndexLogs_2Async + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogs_2Async($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_2'][0]) + { + return $this->getFeedIndexLogs_2AsyncWithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedIndexLogs_2AsyncWithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogs_2AsyncWithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + $request = $this->getFeedIndexLogs_2Request($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedIndexLogs_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedIndexLogs_2Request($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedIndexLogs_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getFeedIndexLogs_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeedIndexLogs_2' + ); + } + + + + + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/index-logs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_from, + 'published_time_from', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_to, + 'published_time_to', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'FeedIndexLogsStatusType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeed_2 + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeed_2($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_2'][0]) + { + list($response) = $this->getFeed_2WithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation getFeed_2WithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeed_2WithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_2'][0]) + { + $request = $this->getFeed_2Request($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeed_2Async + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeed_2Async($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_2'][0]) + { + return $this->getFeed_2AsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeed_2AsyncWithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeed_2AsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + $request = $this->getFeed_2Request($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeed_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeed_2Request($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeed_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getFeed_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeed_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedbackAndCommentUpdates_3 + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedbackAndCommentUpdates_3($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_3'][0]) + { + list($response) = $this->getFeedbackAndCommentUpdates_3WithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType); + return $response; + } + + /** + * Operation getFeedbackAndCommentUpdates_3WithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedbackAndCommentUpdates_3WithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_3'][0]) + { + $request = $this->getFeedbackAndCommentUpdates_3Request($campaign_id, $page_token, $limit, $from_date, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedbackListResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedbackListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedbackAndCommentUpdates_3Async + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdates_3Async($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_3'][0]) + { + return $this->getFeedbackAndCommentUpdates_3AsyncWithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedbackAndCommentUpdates_3AsyncWithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdates_3AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + $request = $this->getFeedbackAndCommentUpdates_3Request($campaign_id, $page_token, $limit, $from_date, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedbackAndCommentUpdates_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedbackAndCommentUpdates_3Request($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedbackAndCommentUpdates_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getFeedbackAndCommentUpdates_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/feedback/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeeds_2 + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeeds_2($campaign_id, string $contentType = self::contentTypes['getFeeds_2'][0]) + { + list($response) = $this->getFeeds_2WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getFeeds_2WithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeeds_2WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds_2'][0]) + { + $request = $this->getFeeds_2Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeeds_2Async + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeeds_2Async($campaign_id, string $contentType = self::contentTypes['getFeeds_2'][0]) + { + return $this->getFeeds_2AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeeds_2AsyncWithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeeds_2AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + $request = $this->getFeeds_2Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeeds_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeeds_2Request($campaign_id, string $contentType = self::contentTypes['getFeeds_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeeds_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getFeeds_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbackComments_3 + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbackComments_3($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_3'][0]) + { + list($response) = $this->getGoodsFeedbackComments_3WithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbackComments_3WithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbackComments_3WithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_3'][0]) + { + $request = $this->getGoodsFeedbackComments_3Request($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbackComments_3Async + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackComments_3Async($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_3'][0]) + { + return $this->getGoodsFeedbackComments_3AsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbackComments_3AsyncWithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackComments_3AsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + $request = $this->getGoodsFeedbackComments_3Request($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbackComments_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbackComments_3Request($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbackComments_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getGoodsFeedbackComments_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_feedback_comments_request' is set + if ($get_goods_feedback_comments_request === null || (is_array($get_goods_feedback_comments_request) && count($get_goods_feedback_comments_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_feedback_comments_request when calling getGoodsFeedbackComments_3' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_comments_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_comments_request)); + } else { + $httpBody = $get_goods_feedback_comments_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbacks_3 + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbacks_3($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_3'][0]) + { + list($response) = $this->getGoodsFeedbacks_3WithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbacks_3WithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbacks_3WithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_3'][0]) + { + $request = $this->getGoodsFeedbacks_3Request($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbacks_3Async + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacks_3Async($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_3'][0]) + { + return $this->getGoodsFeedbacks_3AsyncWithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbacks_3AsyncWithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacks_3AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + $request = $this->getGoodsFeedbacks_3Request($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbacks_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbacks_3Request($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbacks_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getGoodsFeedbacks_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_request)); + } else { + $httpBody = $get_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsStats_2 + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsStats_2($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_2'][0]) + { + list($response) = $this->getGoodsStats_2WithHttpInfo($campaign_id, $get_goods_stats_request, $contentType); + return $response; + } + + /** + * Operation getGoodsStats_2WithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsStats_2WithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_2'][0]) + { + $request = $this->getGoodsStats_2Request($campaign_id, $get_goods_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsStats_2Async + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStats_2Async($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_2'][0]) + { + return $this->getGoodsStats_2AsyncWithHttpInfo($campaign_id, $get_goods_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsStats_2AsyncWithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStats_2AsyncWithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + $request = $this->getGoodsStats_2Request($campaign_id, $get_goods_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsStats_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsStats_2Request($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getGoodsStats_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getGoodsStats_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_stats_request' is set + if ($get_goods_stats_request === null || (is_array($get_goods_stats_request) && count($get_goods_stats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_stats_request when calling getGoodsStats_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/stats/skus'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_stats_request)); + } else { + $httpBody = $get_goods_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getHiddenOffers_3 + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getHiddenOffers_3($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_3'][0]) + { + list($response) = $this->getHiddenOffers_3WithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getHiddenOffers_3WithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getHiddenOffers_3WithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_3'][0]) + { + $request = $this->getHiddenOffers_3Request($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetHiddenOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetHiddenOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getHiddenOffers_3Async + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffers_3Async($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_3'][0]) + { + return $this->getHiddenOffers_3AsyncWithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getHiddenOffers_3AsyncWithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffers_3AsyncWithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + $request = $this->getHiddenOffers_3Request($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getHiddenOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getHiddenOffers_3Request($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getHiddenOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getHiddenOffers_3, must be bigger than or equal to 1.'); + } + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling ExpressApi.getHiddenOffers_3, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offset, + 'offset', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferCardsContentStatus_3 + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferCardsContentStatus_3($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_3'][0]) + { + list($response) = $this->getOfferCardsContentStatus_3WithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + return $response; + } + + /** + * Operation getOfferCardsContentStatus_3WithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferCardsContentStatus_3WithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_3'][0]) + { + $request = $this->getOfferCardsContentStatus_3Request($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferCardsContentStatus_3Async + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatus_3Async($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_3'][0]) + { + return $this->getOfferCardsContentStatus_3AsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferCardsContentStatus_3AsyncWithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatus_3AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + $request = $this->getOfferCardsContentStatus_3Request($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferCardsContentStatus_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferCardsContentStatus_3Request($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferCardsContentStatus_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getOfferCardsContentStatus_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-cards'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_cards_content_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_cards_content_status_request)); + } else { + $httpBody = $get_offer_cards_content_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappingEntries_2 + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOfferMappingEntries_2($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_2'][0]) + { + list($response) = $this->getOfferMappingEntries_2WithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferMappingEntries_2WithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOfferMappingEntries_2WithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_2'][0]) + { + $request = $this->getOfferMappingEntries_2Request($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappingEntries_2Async + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntries_2Async($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_2'][0]) + { + return $this->getOfferMappingEntries_2AsyncWithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappingEntries_2AsyncWithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntries_2AsyncWithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + $request = $this->getOfferMappingEntries_2Request($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappingEntries_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOfferMappingEntries_2Request($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOfferMappingEntries_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getOfferMappingEntries_2, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_sku, + 'shop_sku', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $mapping_kind, + 'mapping_kind', // param base name + 'OfferMappingKindType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $availability, + 'availability', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $category_id, + 'category_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $vendor, + 'vendor', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappings_3 + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferMappings_3($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_3'][0]) + { + list($response) = $this->getOfferMappings_3WithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getOfferMappings_3WithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferMappings_3WithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_3'][0]) + { + $request = $this->getOfferMappings_3Request($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappings_3Async + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappings_3Async($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_3'][0]) + { + return $this->getOfferMappings_3AsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappings_3AsyncWithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappings_3AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + $request = $this->getOfferMappings_3Request($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappings_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferMappings_3Request($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferMappings_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getOfferMappings_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-mappings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_mappings_request)); + } else { + $httpBody = $get_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferRecommendations_3 + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferRecommendations_3($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_3'][0]) + { + list($response) = $this->getOfferRecommendations_3WithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferRecommendations_3WithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferRecommendations_3WithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_3'][0]) + { + $request = $this->getOfferRecommendations_3Request($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferRecommendations_3Async + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendations_3Async($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_3'][0]) + { + return $this->getOfferRecommendations_3AsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferRecommendations_3AsyncWithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendations_3AsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + $request = $this->getOfferRecommendations_3Request($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferRecommendations_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferRecommendations_3Request($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferRecommendations_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getOfferRecommendations_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_offer_recommendations_request' is set + if ($get_offer_recommendations_request === null || (is_array($get_offer_recommendations_request) && count($get_offer_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_offer_recommendations_request when calling getOfferRecommendations_3' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/offers/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_recommendations_request)); + } else { + $httpBody = $get_offer_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOffers_2 + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOffers_2($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_2'][0]) + { + list($response) = $this->getOffers_2WithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getOffers_2WithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOffers_2WithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_2'][0]) + { + $request = $this->getOffers_2Request($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOffers_2Async + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffers_2Async($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_2'][0]) + { + return $this->getOffers_2AsyncWithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOffers_2AsyncWithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffers_2AsyncWithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + $request = $this->getOffers_2Request($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOffers_2Request($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getOffers_2, must be bigger than or equal to 1.'); + } + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling ExpressApi.getOffers_2, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_category_id, + 'shopCategoryId', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $matched, + 'matched', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessBuyerInfo_3 + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessBuyerInfo_3($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_3'][0]) + { + list($response) = $this->getOrderBusinessBuyerInfo_3WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessBuyerInfo_3WithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessBuyerInfo_3WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_3'][0]) + { + $request = $this->getOrderBusinessBuyerInfo_3Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessBuyerInfo_3Async + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfo_3Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_3'][0]) + { + return $this->getOrderBusinessBuyerInfo_3AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessBuyerInfo_3AsyncWithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfo_3AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + $request = $this->getOrderBusinessBuyerInfo_3Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessBuyerInfo_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessBuyerInfo_3Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessBuyerInfo_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getOrderBusinessBuyerInfo_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessBuyerInfo_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/business-buyer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo_3 + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessDocumentsInfo_3($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_3'][0]) + { + list($response) = $this->getOrderBusinessDocumentsInfo_3WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessDocumentsInfo_3WithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessDocumentsInfo_3WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_3'][0]) + { + $request = $this->getOrderBusinessDocumentsInfo_3Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessDocumentsInfo_3Async + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfo_3Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_3'][0]) + { + return $this->getOrderBusinessDocumentsInfo_3AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo_3AsyncWithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfo_3AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + $request = $this->getOrderBusinessDocumentsInfo_3Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessDocumentsInfo_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessDocumentsInfo_3Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessDocumentsInfo_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getOrderBusinessDocumentsInfo_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessDocumentsInfo_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/documents'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderLabelsData_2 + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderLabelsDataResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderLabelsData_2($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_2'][0]) + { + list($response) = $this->getOrderLabelsData_2WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderLabelsData_2WithHttpInfo + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderLabelsDataResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderLabelsData_2WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_2'][0]) + { + $request = $this->getOrderLabelsData_2Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderLabelsDataResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderLabelsDataResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderLabelsDataResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderLabelsDataResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderLabelsDataResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderLabelsData_2Async + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderLabelsData_2Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_2'][0]) + { + return $this->getOrderLabelsData_2AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderLabelsData_2AsyncWithHttpInfo + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderLabelsData_2AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderLabelsDataResponse'; + $request = $this->getOrderLabelsData_2Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderLabelsData_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderLabelsData_2Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderLabelsData_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getOrderLabelsData_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderLabelsData_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/labels/data'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrder_3 + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrder_3($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_3'][0]) + { + list($response) = $this->getOrder_3WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrder_3WithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrder_3WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_3'][0]) + { + $request = $this->getOrder_3Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrder_3Async + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrder_3Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_3'][0]) + { + return $this->getOrder_3AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrder_3AsyncWithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrder_3AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + $request = $this->getOrder_3Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrder_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrder_3Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrder_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getOrder_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrder_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrdersStats_3 + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrdersStats_3($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_3'][0]) + { + list($response) = $this->getOrdersStats_3WithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + return $response; + } + + /** + * Operation getOrdersStats_3WithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrdersStats_3WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_3'][0]) + { + $request = $this->getOrdersStats_3Request($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrdersStats_3Async + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStats_3Async($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_3'][0]) + { + return $this->getOrdersStats_3AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrdersStats_3AsyncWithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStats_3AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + $request = $this->getOrdersStats_3Request($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrdersStats_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrdersStats_3Request($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrdersStats_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getOrdersStats_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/stats/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_orders_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_orders_stats_request)); + } else { + $httpBody = $get_orders_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrders_3 + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrders_3($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_3'][0]) + { + list($response) = $this->getOrders_3WithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOrders_3WithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrders_3WithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_3'][0]) + { + $request = $this->getOrders_3Request($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrders_3Async + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrders_3Async($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_3'][0]) + { + return $this->getOrders_3AsyncWithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrders_3AsyncWithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrders_3AsyncWithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + $request = $this->getOrders_3Request($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrders_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrders_3Request($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrders_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getOrders_3, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling ExpressApi.getOrders_3, must be smaller than or equal to 10000.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $substatus, + 'substatus', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_from, + 'supplierShipmentDateFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_to, + 'supplierShipmentDateTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_from, + 'updatedAtFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_to, + 'updatedAtTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $dispatch_type, + 'dispatchType', // param base name + 'OrderDeliveryDispatchType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $fake, + 'fake', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $has_cis, + 'hasCis', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_waiting_for_cancellation_approve, + 'onlyWaitingForCancellationApprove', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_estimated_delivery, + 'onlyEstimatedDelivery', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_type, + 'buyerType', // param base name + 'OrderBuyerType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPricesByOfferIds_3 + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPricesByOfferIds_3($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_3'][0]) + { + list($response) = $this->getPricesByOfferIds_3WithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + return $response; + } + + /** + * Operation getPricesByOfferIds_3WithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPricesByOfferIds_3WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_3'][0]) + { + $request = $this->getPricesByOfferIds_3Request($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPricesByOfferIds_3Async + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIds_3Async($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_3'][0]) + { + return $this->getPricesByOfferIds_3AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPricesByOfferIds_3AsyncWithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIds_3AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + $request = $this->getPricesByOfferIds_3Request($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPricesByOfferIds_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPricesByOfferIds_3Request($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPricesByOfferIds_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getPricesByOfferIds_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_prices_by_offer_ids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_prices_by_offer_ids_request)); + } else { + $httpBody = $get_prices_by_offer_ids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPrices_3 + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getPrices_3($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_3'][0]) + { + list($response) = $this->getPrices_3WithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType); + return $response; + } + + /** + * Operation getPrices_3WithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getPrices_3WithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_3'][0]) + { + $request = $this->getPrices_3Request($campaign_id, $page_token, $limit, $archived, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPrices_3Async + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPrices_3Async($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_3'][0]) + { + return $this->getPrices_3AsyncWithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPrices_3AsyncWithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPrices_3AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + $request = $this->getPrices_3Request($campaign_id, $page_token, $limit, $archived, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPrices_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getPrices_3Request($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPrices_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getPrices_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromoOffers_3 + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromoOffers_3($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_3'][0]) + { + list($response) = $this->getPromoOffers_3WithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getPromoOffers_3WithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromoOffers_3WithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_3'][0]) + { + $request = $this->getPromoOffers_3Request($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromoOffers_3Async + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffers_3Async($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_3'][0]) + { + return $this->getPromoOffers_3AsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromoOffers_3AsyncWithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffers_3AsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + $request = $this->getPromoOffers_3Request($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromoOffers_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromoOffers_3Request($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromoOffers_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getPromoOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_promo_offers_request' is set + if ($get_promo_offers_request === null || (is_array($get_promo_offers_request) && count($get_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_promo_offers_request when calling getPromoOffers_3' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/promos/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promo_offers_request)); + } else { + $httpBody = $get_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromos_3 + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromos_3($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_3'][0]) + { + list($response) = $this->getPromos_3WithHttpInfo($business_id, $get_promos_request, $contentType); + return $response; + } + + /** + * Operation getPromos_3WithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromos_3WithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_3'][0]) + { + $request = $this->getPromos_3Request($business_id, $get_promos_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromosResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromosResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromosResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromosResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromos_3Async + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromos_3Async($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_3'][0]) + { + return $this->getPromos_3AsyncWithHttpInfo($business_id, $get_promos_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromos_3AsyncWithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromos_3AsyncWithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + $request = $this->getPromos_3Request($business_id, $get_promos_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromos_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromos_3Request($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromos_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getPromos_3, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/promos'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promos_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promos_request)); + } else { + $httpBody = $get_promos_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getQualityRatingDetails_2 + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingDetailsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatingDetails_2($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_2'][0]) + { + list($response) = $this->getQualityRatingDetails_2WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getQualityRatingDetails_2WithHttpInfo + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingDetailsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatingDetails_2WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_2'][0]) + { + $request = $this->getQualityRatingDetails_2Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingDetailsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingDetailsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatingDetails_2Async + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingDetails_2Async($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_2'][0]) + { + return $this->getQualityRatingDetails_2AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatingDetails_2AsyncWithHttpInfo + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingDetails_2AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse'; + $request = $this->getQualityRatingDetails_2Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatingDetails_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatingDetails_2Request($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getQualityRatingDetails_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getQualityRatingDetails_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/ratings/quality/details'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getQualityRatings_3 + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatings_3($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_3'][0]) + { + list($response) = $this->getQualityRatings_3WithHttpInfo($business_id, $get_quality_rating_request, $contentType); + return $response; + } + + /** + * Operation getQualityRatings_3WithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatings_3WithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_3'][0]) + { + $request = $this->getQualityRatings_3Request($business_id, $get_quality_rating_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatings_3Async + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatings_3Async($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_3'][0]) + { + return $this->getQualityRatings_3AsyncWithHttpInfo($business_id, $get_quality_rating_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatings_3AsyncWithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatings_3AsyncWithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + $request = $this->getQualityRatings_3Request($business_id, $get_quality_rating_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatings_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatings_3Request($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getQualityRatings_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getQualityRatings_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quality_rating_request' is set + if ($get_quality_rating_request === null || (is_array($get_quality_rating_request) && count($get_quality_rating_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quality_rating_request when calling getQualityRatings_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/ratings/quality'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quality_rating_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quality_rating_request)); + } else { + $httpBody = $get_quality_rating_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReportInfo_3 + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReportInfo_3($report_id, string $contentType = self::contentTypes['getReportInfo_3'][0]) + { + list($response) = $this->getReportInfo_3WithHttpInfo($report_id, $contentType); + return $response; + } + + /** + * Operation getReportInfo_3WithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReportInfo_3WithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo_3'][0]) + { + $request = $this->getReportInfo_3Request($report_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReportInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReportInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReportInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReportInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReportInfo_3Async + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfo_3Async($report_id, string $contentType = self::contentTypes['getReportInfo_3'][0]) + { + return $this->getReportInfo_3AsyncWithHttpInfo($report_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReportInfo_3AsyncWithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfo_3AsyncWithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + $request = $this->getReportInfo_3Request($report_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReportInfo_3' + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReportInfo_3Request($report_id, string $contentType = self::contentTypes['getReportInfo_3'][0]) + { + + // verify the required parameter 'report_id' is set + if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $report_id when calling getReportInfo_3' + ); + } + + + $resourcePath = '/reports/info/{reportId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($report_id !== null) { + $resourcePath = str_replace( + '{' . 'reportId' . '}', + ObjectSerializer::toPathValue($report_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnApplication_2 + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnApplication_2($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_2'][0]) + { + list($response) = $this->getReturnApplication_2WithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturnApplication_2WithHttpInfo + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnApplication_2WithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_2'][0]) + { + $request = $this->getReturnApplication_2Request($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnApplication_2Async + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnApplication_2Async($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_2'][0]) + { + return $this->getReturnApplication_2AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnApplication_2AsyncWithHttpInfo + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnApplication_2AsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_2'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnApplication_2Request($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnApplication_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnApplication_2Request($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnApplication_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getReturnApplication_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnApplication_2' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnApplication_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/application'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnPhoto_2 + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnPhoto_2($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_2'][0]) + { + list($response) = $this->getReturnPhoto_2WithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + return $response; + } + + /** + * Operation getReturnPhoto_2WithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnPhoto_2WithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_2'][0]) + { + $request = $this->getReturnPhoto_2Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnPhoto_2Async + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhoto_2Async($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_2'][0]) + { + return $this->getReturnPhoto_2AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnPhoto_2AsyncWithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhoto_2AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_2'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnPhoto_2Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnPhoto_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnPhoto_2Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnPhoto_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getReturnPhoto_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnPhoto_2' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnPhoto_2' + ); + } + + // verify the required parameter 'item_id' is set + if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $item_id when calling getReturnPhoto_2' + ); + } + + // verify the required parameter 'image_hash' is set + if ($image_hash === null || (is_array($image_hash) && count($image_hash) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $image_hash when calling getReturnPhoto_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision/{itemId}/image/{imageHash}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + // path params + if ($item_id !== null) { + $resourcePath = str_replace( + '{' . 'itemId' . '}', + ObjectSerializer::toPathValue($item_id), + $resourcePath + ); + } + // path params + if ($image_hash !== null) { + $resourcePath = str_replace( + '{' . 'imageHash' . '}', + ObjectSerializer::toPathValue($image_hash), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturn_2 + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturn_2($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_2'][0]) + { + list($response) = $this->getReturn_2WithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturn_2WithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturn_2WithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_2'][0]) + { + $request = $this->getReturn_2Request($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturn_2Async + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturn_2Async($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_2'][0]) + { + return $this->getReturn_2AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturn_2AsyncWithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturn_2AsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + $request = $this->getReturn_2Request($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturn_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturn_2Request($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturn_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getReturn_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturn_2' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturn_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturns_2 + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturns_2($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_2'][0]) + { + list($response) = $this->getReturns_2WithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + return $response; + } + + /** + * Operation getReturns_2WithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturns_2WithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_2'][0]) + { + $request = $this->getReturns_2Request($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturns_2Async + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturns_2Async($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_2'][0]) + { + return $this->getReturns_2AsyncWithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturns_2AsyncWithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturns_2AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + $request = $this->getReturns_2Request($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturns_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturns_2Request($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturns_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getReturns_2, must be bigger than or equal to 1.'); + } + + + + if ($order_ids !== null && count($order_ids) > 50) { + throw new \InvalidArgumentException('invalid value for "$order_ids" when calling ExpressApi.getReturns_2, number of items must be less than or equal to 50.'); + } + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/returns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $statuses, + 'statuses', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $type, + 'type', // param base name + 'ReturnType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date2, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date2, + 'to_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getStocks_3 + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getStocks_3($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_3'][0]) + { + list($response) = $this->getStocks_3WithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + return $response; + } + + /** + * Operation getStocks_3WithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getStocks_3WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_3'][0]) + { + $request = $this->getStocks_3Request($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehouseStocksResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehouseStocksResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getStocks_3Async + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocks_3Async($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_3'][0]) + { + return $this->getStocks_3AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getStocks_3AsyncWithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocks_3AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + $request = $this->getStocks_3Request($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getStocks_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getStocks_3Request($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getStocks_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getStocks_3, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_warehouse_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_warehouse_stocks_request)); + } else { + $httpBody = $get_warehouse_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappingEntries_2 + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedOfferMappingEntries_2($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_2'][0]) + { + list($response) = $this->getSuggestedOfferMappingEntries_2WithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappingEntries_2WithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedOfferMappingEntries_2WithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_2'][0]) + { + $request = $this->getSuggestedOfferMappingEntries_2Request($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappingEntries_2Async + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntries_2Async($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_2'][0]) + { + return $this->getSuggestedOfferMappingEntries_2AsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappingEntries_2AsyncWithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntries_2AsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + $request = $this->getSuggestedOfferMappingEntries_2Request($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappingEntries_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedOfferMappingEntries_2Request($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedOfferMappingEntries_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getSuggestedOfferMappingEntries_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_suggested_offer_mapping_entries_request' is set + if ($get_suggested_offer_mapping_entries_request === null || (is_array($get_suggested_offer_mapping_entries_request) && count($get_suggested_offer_mapping_entries_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_suggested_offer_mapping_entries_request when calling getSuggestedOfferMappingEntries_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mapping_entries_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mapping_entries_request)); + } else { + $httpBody = $get_suggested_offer_mapping_entries_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappings_3 + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getSuggestedOfferMappings_3($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_3'][0]) + { + list($response) = $this->getSuggestedOfferMappings_3WithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappings_3WithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getSuggestedOfferMappings_3WithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_3'][0]) + { + $request = $this->getSuggestedOfferMappings_3Request($business_id, $get_suggested_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappings_3Async + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappings_3Async($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_3'][0]) + { + return $this->getSuggestedOfferMappings_3AsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappings_3AsyncWithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappings_3AsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + $request = $this->getSuggestedOfferMappings_3Request($business_id, $get_suggested_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappings_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getSuggestedOfferMappings_3Request($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getSuggestedOfferMappings_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getSuggestedOfferMappings_3, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/offer-mappings/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mappings_request)); + } else { + $httpBody = $get_suggested_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedPrices_2 + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedPrices_2($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_2'][0]) + { + list($response) = $this->getSuggestedPrices_2WithHttpInfo($campaign_id, $suggest_prices_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedPrices_2WithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedPrices_2WithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_2'][0]) + { + $request = $this->getSuggestedPrices_2Request($campaign_id, $suggest_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SuggestPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SuggestPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SuggestPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SuggestPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedPrices_2Async + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPrices_2Async($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_2'][0]) + { + return $this->getSuggestedPrices_2AsyncWithHttpInfo($campaign_id, $suggest_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedPrices_2AsyncWithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPrices_2AsyncWithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + $request = $this->getSuggestedPrices_2Request($campaign_id, $suggest_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedPrices_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedPrices_2Request($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedPrices_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.getSuggestedPrices_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'suggest_prices_request' is set + if ($suggest_prices_request === null || (is_array($suggest_prices_request) && count($suggest_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $suggest_prices_request when calling getSuggestedPrices_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($suggest_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($suggest_prices_request)); + } else { + $httpBody = $suggest_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getWarehouses_2 + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getWarehouses_2($business_id, string $contentType = self::contentTypes['getWarehouses_2'][0]) + { + list($response) = $this->getWarehouses_2WithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getWarehouses_2WithHttpInfo + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getWarehouses_2WithHttpInfo($business_id, string $contentType = self::contentTypes['getWarehouses_2'][0]) + { + $request = $this->getWarehouses_2Request($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehousesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehousesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehousesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehousesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehousesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getWarehouses_2Async + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getWarehouses_2Async($business_id, string $contentType = self::contentTypes['getWarehouses_2'][0]) + { + return $this->getWarehouses_2AsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getWarehouses_2AsyncWithHttpInfo + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getWarehouses_2AsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getWarehouses_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehousesResponse'; + $request = $this->getWarehouses_2Request($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getWarehouses_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getWarehouses_2Request($business_id, string $contentType = self::contentTypes['getWarehouses_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getWarehouses_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.getWarehouses_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/warehouses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation provideOrderItemIdentifiers_2 + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function provideOrderItemIdentifiers_2($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_2'][0]) + { + list($response) = $this->provideOrderItemIdentifiers_2WithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + return $response; + } + + /** + * Operation provideOrderItemIdentifiers_2WithHttpInfo + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function provideOrderItemIdentifiers_2WithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_2'][0]) + { + $request = $this->provideOrderItemIdentifiers_2Request($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation provideOrderItemIdentifiers_2Async + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderItemIdentifiers_2Async($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_2'][0]) + { + return $this->provideOrderItemIdentifiers_2AsyncWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation provideOrderItemIdentifiers_2AsyncWithHttpInfo + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderItemIdentifiers_2AsyncWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse'; + $request = $this->provideOrderItemIdentifiers_2Request($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'provideOrderItemIdentifiers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function provideOrderItemIdentifiers_2Request($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling provideOrderItemIdentifiers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.provideOrderItemIdentifiers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling provideOrderItemIdentifiers_2' + ); + } + + // verify the required parameter 'provide_order_item_identifiers_request' is set + if ($provide_order_item_identifiers_request === null || (is_array($provide_order_item_identifiers_request) && count($provide_order_item_identifiers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $provide_order_item_identifiers_request when calling provideOrderItemIdentifiers_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/identifiers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($provide_order_item_identifiers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($provide_order_item_identifiers_request)); + } else { + $httpBody = $provide_order_item_identifiers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForBusiness_3 + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForBusiness_3($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_3'][0]) + { + list($response) = $this->putBidsForBusiness_3WithHttpInfo($business_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForBusiness_3WithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForBusiness_3WithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_3'][0]) + { + $request = $this->putBidsForBusiness_3Request($business_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForBusiness_3Async + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusiness_3Async($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_3'][0]) + { + return $this->putBidsForBusiness_3AsyncWithHttpInfo($business_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForBusiness_3AsyncWithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusiness_3AsyncWithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForBusiness_3Request($business_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForBusiness_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForBusiness_3Request($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling putBidsForBusiness_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.putBidsForBusiness_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForBusiness_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForCampaign_2 + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForCampaign_2($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_2'][0]) + { + list($response) = $this->putBidsForCampaign_2WithHttpInfo($campaign_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForCampaign_2WithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForCampaign_2WithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_2'][0]) + { + $request = $this->putBidsForCampaign_2Request($campaign_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForCampaign_2Async + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaign_2Async($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_2'][0]) + { + return $this->putBidsForCampaign_2AsyncWithHttpInfo($campaign_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForCampaign_2AsyncWithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaign_2AsyncWithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForCampaign_2Request($campaign_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForCampaign_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForCampaign_2Request($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling putBidsForCampaign_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.putBidsForCampaign_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForCampaign_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation refreshFeed_2 + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function refreshFeed_2($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_2'][0]) + { + list($response) = $this->refreshFeed_2WithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation refreshFeed_2WithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function refreshFeed_2WithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_2'][0]) + { + $request = $this->refreshFeed_2Request($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation refreshFeed_2Async + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeed_2Async($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_2'][0]) + { + return $this->refreshFeed_2AsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation refreshFeed_2AsyncWithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeed_2AsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->refreshFeed_2Request($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'refreshFeed_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function refreshFeed_2Request($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling refreshFeed_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.refreshFeed_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling refreshFeed_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/refresh'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionChildren_3 + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionChildren_3($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_3'][0]) + { + list($response) = $this->searchRegionChildren_3WithHttpInfo($region_id, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation searchRegionChildren_3WithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionChildren_3WithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_3'][0]) + { + $request = $this->searchRegionChildren_3Request($region_id, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionChildren_3Async + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildren_3Async($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_3'][0]) + { + return $this->searchRegionChildren_3AsyncWithHttpInfo($region_id, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionChildren_3AsyncWithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildren_3AsyncWithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + $request = $this->searchRegionChildren_3Request($region_id, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionChildren_3' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionChildren_3Request($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_3'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionChildren_3' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling ExpressApi.searchRegionChildren_3, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/regions/{regionId}/children'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsById_3 + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsById_3($region_id, string $contentType = self::contentTypes['searchRegionsById_3'][0]) + { + list($response) = $this->searchRegionsById_3WithHttpInfo($region_id, $contentType); + return $response; + } + + /** + * Operation searchRegionsById_3WithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsById_3WithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById_3'][0]) + { + $request = $this->searchRegionsById_3Request($region_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsById_3Async + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsById_3Async($region_id, string $contentType = self::contentTypes['searchRegionsById_3'][0]) + { + return $this->searchRegionsById_3AsyncWithHttpInfo($region_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsById_3AsyncWithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsById_3AsyncWithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsById_3Request($region_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsById_3' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsById_3Request($region_id, string $contentType = self::contentTypes['searchRegionsById_3'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionsById_3' + ); + } + + + $resourcePath = '/regions/{regionId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsByName_3 + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsByName_3($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_3'][0]) + { + list($response) = $this->searchRegionsByName_3WithHttpInfo($name, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation searchRegionsByName_3WithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsByName_3WithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_3'][0]) + { + $request = $this->searchRegionsByName_3Request($name, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsByName_3Async + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByName_3Async($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_3'][0]) + { + return $this->searchRegionsByName_3AsyncWithHttpInfo($name, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsByName_3AsyncWithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByName_3AsyncWithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsByName_3Request($name, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsByName_3' + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsByName_3Request($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_3'][0]) + { + + // verify the required parameter 'name' is set + if ($name === null || (is_array($name) && count($name) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $name when calling searchRegionsByName_3' + ); + } + + + + + $resourcePath = '/regions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $name, + 'name', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendFileToChat_3 + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendFileToChat_3($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_3'][0]) + { + list($response) = $this->sendFileToChat_3WithHttpInfo($business_id, $chat_id, $file, $contentType); + return $response; + } + + /** + * Operation sendFileToChat_3WithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendFileToChat_3WithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_3'][0]) + { + $request = $this->sendFileToChat_3Request($business_id, $chat_id, $file, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendFileToChat_3Async + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChat_3Async($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_3'][0]) + { + return $this->sendFileToChat_3AsyncWithHttpInfo($business_id, $chat_id, $file, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendFileToChat_3AsyncWithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChat_3AsyncWithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendFileToChat_3Request($business_id, $chat_id, $file, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendFileToChat_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendFileToChat_3Request($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendFileToChat_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.sendFileToChat_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendFileToChat_3' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling ExpressApi.sendFileToChat_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'file' is set + if ($file === null || (is_array($file) && count($file) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $file when calling sendFileToChat_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/file/send'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + // form params + if ($file !== null) { + $multipart = true; + $formParams['file'] = []; + $paramFiles = is_array($file) ? $file : [$file]; + foreach ($paramFiles as $paramFile) { + $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( + ObjectSerializer::toFormValue($paramFile), + 'rb' + ); + } + } + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendMessageToChat_3 + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendMessageToChat_3($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_3'][0]) + { + list($response) = $this->sendMessageToChat_3WithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType); + return $response; + } + + /** + * Operation sendMessageToChat_3WithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendMessageToChat_3WithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_3'][0]) + { + $request = $this->sendMessageToChat_3Request($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendMessageToChat_3Async + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChat_3Async($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_3'][0]) + { + return $this->sendMessageToChat_3AsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendMessageToChat_3AsyncWithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChat_3AsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendMessageToChat_3Request($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendMessageToChat_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendMessageToChat_3Request($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendMessageToChat_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.sendMessageToChat_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendMessageToChat_3' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling ExpressApi.sendMessageToChat_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'send_message_to_chat_request' is set + if ($send_message_to_chat_request === null || (is_array($send_message_to_chat_request) && count($send_message_to_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $send_message_to_chat_request when calling sendMessageToChat_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/message'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($send_message_to_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($send_message_to_chat_request)); + } else { + $httpBody = $send_message_to_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setFeedParams_2 + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function setFeedParams_2($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_2'][0]) + { + list($response) = $this->setFeedParams_2WithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType); + return $response; + } + + /** + * Operation setFeedParams_2WithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function setFeedParams_2WithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_2'][0]) + { + $request = $this->setFeedParams_2Request($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setFeedParams_2Async + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParams_2Async($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_2'][0]) + { + return $this->setFeedParams_2AsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setFeedParams_2AsyncWithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParams_2AsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setFeedParams_2Request($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setFeedParams_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function setFeedParams_2Request($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setFeedParams_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.setFeedParams_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling setFeedParams_2' + ); + } + + // verify the required parameter 'set_feed_params_request' is set + if ($set_feed_params_request === null || (is_array($set_feed_params_request) && count($set_feed_params_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_feed_params_request when calling setFeedParams_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/params'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_feed_params_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_feed_params_request)); + } else { + $httpBody = $set_feed_params_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderBoxLayout_1 + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SetOrderBoxLayoutResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderBoxLayout_1($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_1'][0]) + { + list($response) = $this->setOrderBoxLayout_1WithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + return $response; + } + + /** + * Operation setOrderBoxLayout_1WithHttpInfo + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SetOrderBoxLayoutResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderBoxLayout_1WithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_1'][0]) + { + $request = $this->setOrderBoxLayout_1Request($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SetOrderBoxLayoutResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SetOrderBoxLayoutResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderBoxLayout_1Async + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderBoxLayout_1Async($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_1'][0]) + { + return $this->setOrderBoxLayout_1AsyncWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderBoxLayout_1AsyncWithHttpInfo + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderBoxLayout_1AsyncWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse'; + $request = $this->setOrderBoxLayout_1Request($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderBoxLayout_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderBoxLayout_1Request($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderBoxLayout_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.setOrderBoxLayout_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderBoxLayout_1' + ); + } + + // verify the required parameter 'set_order_box_layout_request' is set + if ($set_order_box_layout_request === null || (is_array($set_order_box_layout_request) && count($set_order_box_layout_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_box_layout_request when calling setOrderBoxLayout_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/boxes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_box_layout_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_box_layout_request)); + } else { + $httpBody = $set_order_box_layout_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderShipmentBoxes_2 + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SetOrderShipmentBoxesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderShipmentBoxes_2($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_2'][0]) + { + list($response) = $this->setOrderShipmentBoxes_2WithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + return $response; + } + + /** + * Operation setOrderShipmentBoxes_2WithHttpInfo + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SetOrderShipmentBoxesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderShipmentBoxes_2WithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_2'][0]) + { + $request = $this->setOrderShipmentBoxes_2Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderShipmentBoxes_2Async + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderShipmentBoxes_2Async($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_2'][0]) + { + return $this->setOrderShipmentBoxes_2AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderShipmentBoxes_2AsyncWithHttpInfo + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderShipmentBoxes_2AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse'; + $request = $this->setOrderShipmentBoxes_2Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderShipmentBoxes_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderShipmentBoxes_2Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderShipmentBoxes_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.setOrderShipmentBoxes_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderShipmentBoxes_2' + ); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling setOrderShipmentBoxes_2' + ); + } + + // verify the required parameter 'set_order_shipment_boxes_request' is set + if ($set_order_shipment_boxes_request === null || (is_array($set_order_shipment_boxes_request) && count($set_order_shipment_boxes_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_shipment_boxes_request when calling setOrderShipmentBoxes_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_shipment_boxes_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_shipment_boxes_request)); + } else { + $httpBody = $set_order_shipment_boxes_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation skipGoodsFeedbacksReaction_3 + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function skipGoodsFeedbacksReaction_3($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_3'][0]) + { + list($response) = $this->skipGoodsFeedbacksReaction_3WithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType); + return $response; + } + + /** + * Operation skipGoodsFeedbacksReaction_3WithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function skipGoodsFeedbacksReaction_3WithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_3'][0]) + { + $request = $this->skipGoodsFeedbacksReaction_3Request($business_id, $skip_goods_feedback_reaction_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation skipGoodsFeedbacksReaction_3Async + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReaction_3Async($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_3'][0]) + { + return $this->skipGoodsFeedbacksReaction_3AsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation skipGoodsFeedbacksReaction_3AsyncWithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReaction_3AsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->skipGoodsFeedbacksReaction_3Request($business_id, $skip_goods_feedback_reaction_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'skipGoodsFeedbacksReaction_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function skipGoodsFeedbacksReaction_3Request($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling skipGoodsFeedbacksReaction_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.skipGoodsFeedbacksReaction_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'skip_goods_feedback_reaction_request' is set + if ($skip_goods_feedback_reaction_request === null || (is_array($skip_goods_feedback_reaction_request) && count($skip_goods_feedback_reaction_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $skip_goods_feedback_reaction_request when calling skipGoodsFeedbacksReaction_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/skip-reaction'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($skip_goods_feedback_reaction_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($skip_goods_feedback_reaction_request)); + } else { + $httpBody = $skip_goods_feedback_reaction_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateBusinessPrices_3 + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateBusinessPrices_3($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_3'][0]) + { + list($response) = $this->updateBusinessPrices_3WithHttpInfo($business_id, $update_business_prices_request, $contentType); + return $response; + } + + /** + * Operation updateBusinessPrices_3WithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateBusinessPrices_3WithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_3'][0]) + { + $request = $this->updateBusinessPrices_3Request($business_id, $update_business_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateBusinessPrices_3Async + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPrices_3Async($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_3'][0]) + { + return $this->updateBusinessPrices_3AsyncWithHttpInfo($business_id, $update_business_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateBusinessPrices_3AsyncWithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPrices_3AsyncWithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateBusinessPrices_3Request($business_id, $update_business_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateBusinessPrices_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateBusinessPrices_3Request($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateBusinessPrices_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.updateBusinessPrices_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_business_prices_request' is set + if ($update_business_prices_request === null || (is_array($update_business_prices_request) && count($update_business_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_business_prices_request when calling updateBusinessPrices_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_business_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_business_prices_request)); + } else { + $httpBody = $update_business_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateCampaignOffers_3 + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateCampaignOffers_3($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_3'][0]) + { + list($response) = $this->updateCampaignOffers_3WithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation updateCampaignOffers_3WithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateCampaignOffers_3WithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_3'][0]) + { + $request = $this->updateCampaignOffers_3Request($campaign_id, $update_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateCampaignOffers_3Async + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffers_3Async($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_3'][0]) + { + return $this->updateCampaignOffers_3AsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateCampaignOffers_3AsyncWithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffers_3AsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateCampaignOffers_3Request($campaign_id, $update_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateCampaignOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateCampaignOffers_3Request($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateCampaignOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.updateCampaignOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_campaign_offers_request' is set + if ($update_campaign_offers_request === null || (is_array($update_campaign_offers_request) && count($update_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_campaign_offers_request when calling updateCampaignOffers_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_campaign_offers_request)); + } else { + $httpBody = $update_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateGoodsFeedbackComment_3 + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateGoodsFeedbackComment_3($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_3'][0]) + { + list($response) = $this->updateGoodsFeedbackComment_3WithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation updateGoodsFeedbackComment_3WithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateGoodsFeedbackComment_3WithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_3'][0]) + { + $request = $this->updateGoodsFeedbackComment_3Request($business_id, $update_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateGoodsFeedbackComment_3Async + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackComment_3Async($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_3'][0]) + { + return $this->updateGoodsFeedbackComment_3AsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateGoodsFeedbackComment_3AsyncWithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackComment_3AsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + $request = $this->updateGoodsFeedbackComment_3Request($business_id, $update_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateGoodsFeedbackComment_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateGoodsFeedbackComment_3Request($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateGoodsFeedbackComment_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.updateGoodsFeedbackComment_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_goods_feedback_comment_request' is set + if ($update_goods_feedback_comment_request === null || (is_array($update_goods_feedback_comment_request) && count($update_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_goods_feedback_comment_request when calling updateGoodsFeedbackComment_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_goods_feedback_comment_request)); + } else { + $httpBody = $update_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferContent_3 + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferContent_3($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_3'][0]) + { + list($response) = $this->updateOfferContent_3WithHttpInfo($business_id, $update_offer_content_request, $contentType); + return $response; + } + + /** + * Operation updateOfferContent_3WithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferContent_3WithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_3'][0]) + { + $request = $this->updateOfferContent_3Request($business_id, $update_offer_content_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferContentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferContentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferContent_3Async + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContent_3Async($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_3'][0]) + { + return $this->updateOfferContent_3AsyncWithHttpInfo($business_id, $update_offer_content_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferContent_3AsyncWithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContent_3AsyncWithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + $request = $this->updateOfferContent_3Request($business_id, $update_offer_content_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferContent_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferContent_3Request($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferContent_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.updateOfferContent_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_content_request' is set + if ($update_offer_content_request === null || (is_array($update_offer_content_request) && count($update_offer_content_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_content_request when calling updateOfferContent_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-cards/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_content_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_content_request)); + } else { + $httpBody = $update_offer_content_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappingEntries_2 + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function updateOfferMappingEntries_2($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_2'][0]) + { + list($response) = $this->updateOfferMappingEntries_2WithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappingEntries_2WithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function updateOfferMappingEntries_2WithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_2'][0]) + { + $request = $this->updateOfferMappingEntries_2Request($campaign_id, $update_offer_mapping_entry_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappingEntries_2Async + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntries_2Async($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_2'][0]) + { + return $this->updateOfferMappingEntries_2AsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappingEntries_2AsyncWithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntries_2AsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOfferMappingEntries_2Request($campaign_id, $update_offer_mapping_entry_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappingEntries_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function updateOfferMappingEntries_2Request($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOfferMappingEntries_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.updateOfferMappingEntries_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mapping_entry_request' is set + if ($update_offer_mapping_entry_request === null || (is_array($update_offer_mapping_entry_request) && count($update_offer_mapping_entry_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mapping_entry_request when calling updateOfferMappingEntries_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mapping_entry_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mapping_entry_request)); + } else { + $httpBody = $update_offer_mapping_entry_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappings_3 + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferMappings_3($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_3'][0]) + { + list($response) = $this->updateOfferMappings_3WithHttpInfo($business_id, $update_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappings_3WithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferMappings_3WithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_3'][0]) + { + $request = $this->updateOfferMappings_3Request($business_id, $update_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappings_3Async + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappings_3Async($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_3'][0]) + { + return $this->updateOfferMappings_3AsyncWithHttpInfo($business_id, $update_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappings_3AsyncWithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappings_3AsyncWithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + $request = $this->updateOfferMappings_3Request($business_id, $update_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappings_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferMappings_3Request($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferMappings_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.updateOfferMappings_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mappings_request' is set + if ($update_offer_mappings_request === null || (is_array($update_offer_mappings_request) && count($update_offer_mappings_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mappings_request when calling updateOfferMappings_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mappings_request)); + } else { + $httpBody = $update_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderItems_2 + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function updateOrderItems_2($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_2'][0]) + { + $this->updateOrderItems_2WithHttpInfo($campaign_id, $order_id, $update_order_item_request, $contentType); + } + + /** + * Operation updateOrderItems_2WithHttpInfo + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderItems_2WithHttpInfo($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_2'][0]) + { + $request = $this->updateOrderItems_2Request($campaign_id, $order_id, $update_order_item_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderItems_2Async + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderItems_2Async($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_2'][0]) + { + return $this->updateOrderItems_2AsyncWithHttpInfo($campaign_id, $order_id, $update_order_item_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderItems_2AsyncWithHttpInfo + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderItems_2AsyncWithHttpInfo($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_2'][0]) + { + $returnType = ''; + $request = $this->updateOrderItems_2Request($campaign_id, $order_id, $update_order_item_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderItems_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderItems_2Request($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderItems_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.updateOrderItems_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderItems_2' + ); + } + + // verify the required parameter 'update_order_item_request' is set + if ($update_order_item_request === null || (is_array($update_order_item_request) && count($update_order_item_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_item_request when calling updateOrderItems_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/items'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_item_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_item_request)); + } else { + $httpBody = $update_order_item_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStatus_2 + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOrderStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStatus_2($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_2'][0]) + { + list($response) = $this->updateOrderStatus_2WithHttpInfo($campaign_id, $order_id, $update_order_status_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStatus_2WithHttpInfo + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOrderStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStatus_2WithHttpInfo($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_2'][0]) + { + $request = $this->updateOrderStatus_2Request($campaign_id, $order_id, $update_order_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOrderStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOrderStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOrderStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOrderStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStatus_2Async + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatus_2Async($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_2'][0]) + { + return $this->updateOrderStatus_2AsyncWithHttpInfo($campaign_id, $order_id, $update_order_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStatus_2AsyncWithHttpInfo + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatus_2AsyncWithHttpInfo($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusResponse'; + $request = $this->updateOrderStatus_2Request($campaign_id, $order_id, $update_order_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStatus_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStatus_2Request($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStatus_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.updateOrderStatus_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderStatus_2' + ); + } + + // verify the required parameter 'update_order_status_request' is set + if ($update_order_status_request === null || (is_array($update_order_status_request) && count($update_order_status_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_status_request when calling updateOrderStatus_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_status_request)); + } else { + $httpBody = $update_order_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStatuses_2 + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOrderStatusesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStatuses_2($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_2'][0]) + { + list($response) = $this->updateOrderStatuses_2WithHttpInfo($campaign_id, $update_order_statuses_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStatuses_2WithHttpInfo + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOrderStatusesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStatuses_2WithHttpInfo($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_2'][0]) + { + $request = $this->updateOrderStatuses_2Request($campaign_id, $update_order_statuses_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOrderStatusesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOrderStatusesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOrderStatusesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOrderStatusesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStatuses_2Async + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatuses_2Async($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_2'][0]) + { + return $this->updateOrderStatuses_2AsyncWithHttpInfo($campaign_id, $update_order_statuses_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStatuses_2AsyncWithHttpInfo + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatuses_2AsyncWithHttpInfo($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusesResponse'; + $request = $this->updateOrderStatuses_2Request($campaign_id, $update_order_statuses_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStatuses_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStatuses_2Request($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStatuses_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.updateOrderStatuses_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_order_statuses_request' is set + if ($update_order_statuses_request === null || (is_array($update_order_statuses_request) && count($update_order_statuses_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_statuses_request when calling updateOrderStatuses_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/status-update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_statuses_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_statuses_request)); + } else { + $httpBody = $update_order_statuses_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePrices_3 + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePrices_3($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_3'][0]) + { + list($response) = $this->updatePrices_3WithHttpInfo($campaign_id, $update_prices_request, $contentType); + return $response; + } + + /** + * Operation updatePrices_3WithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePrices_3WithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_3'][0]) + { + $request = $this->updatePrices_3Request($campaign_id, $update_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePrices_3Async + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePrices_3Async($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_3'][0]) + { + return $this->updatePrices_3AsyncWithHttpInfo($campaign_id, $update_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePrices_3AsyncWithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePrices_3AsyncWithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updatePrices_3Request($campaign_id, $update_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePrices_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePrices_3Request($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updatePrices_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.updatePrices_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_prices_request' is set + if ($update_prices_request === null || (is_array($update_prices_request) && count($update_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_prices_request when calling updatePrices_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_prices_request)); + } else { + $httpBody = $update_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePromoOffers_3 + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePromoOffers_3($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_3'][0]) + { + list($response) = $this->updatePromoOffers_3WithHttpInfo($business_id, $update_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation updatePromoOffers_3WithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePromoOffers_3WithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_3'][0]) + { + $request = $this->updatePromoOffers_3Request($business_id, $update_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdatePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdatePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePromoOffers_3Async + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffers_3Async($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_3'][0]) + { + return $this->updatePromoOffers_3AsyncWithHttpInfo($business_id, $update_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePromoOffers_3AsyncWithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffers_3AsyncWithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + $request = $this->updatePromoOffers_3Request($business_id, $update_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePromoOffers_3' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePromoOffers_3Request($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_3'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updatePromoOffers_3' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling ExpressApi.updatePromoOffers_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_promo_offers_request' is set + if ($update_promo_offers_request === null || (is_array($update_promo_offers_request) && count($update_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_promo_offers_request when calling updatePromoOffers_3' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_promo_offers_request)); + } else { + $httpBody = $update_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateStocks_2 + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateStocks_2($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_2'][0]) + { + list($response) = $this->updateStocks_2WithHttpInfo($campaign_id, $update_stocks_request, $contentType); + return $response; + } + + /** + * Operation updateStocks_2WithHttpInfo + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateStocks_2WithHttpInfo($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_2'][0]) + { + $request = $this->updateStocks_2Request($campaign_id, $update_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateStocks_2Async + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateStocks_2Async($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_2'][0]) + { + return $this->updateStocks_2AsyncWithHttpInfo($campaign_id, $update_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateStocks_2AsyncWithHttpInfo + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateStocks_2AsyncWithHttpInfo($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateStocks_2Request($campaign_id, $update_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateStocks_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateStocks_2Request($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateStocks_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.updateStocks_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_stocks_request' is set + if ($update_stocks_request === null || (is_array($update_stocks_request) && count($update_stocks_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_stocks_request when calling updateStocks_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_stocks_request)); + } else { + $httpBody = $update_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation verifyOrderEac_0 + * + * Передача кода подтверждения + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\VerifyOrderEacResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function verifyOrderEac_0($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac_0'][0]) + { + list($response) = $this->verifyOrderEac_0WithHttpInfo($campaign_id, $order_id, $verify_order_eac_request, $contentType); + return $response; + } + + /** + * Operation verifyOrderEac_0WithHttpInfo + * + * Передача кода подтверждения + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\VerifyOrderEacResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function verifyOrderEac_0WithHttpInfo($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac_0'][0]) + { + $request = $this->verifyOrderEac_0Request($campaign_id, $order_id, $verify_order_eac_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\VerifyOrderEacResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\VerifyOrderEacResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\VerifyOrderEacResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\VerifyOrderEacResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\VerifyOrderEacResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation verifyOrderEac_0Async + * + * Передача кода подтверждения + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function verifyOrderEac_0Async($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac_0'][0]) + { + return $this->verifyOrderEac_0AsyncWithHttpInfo($campaign_id, $order_id, $verify_order_eac_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation verifyOrderEac_0AsyncWithHttpInfo + * + * Передача кода подтверждения + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function verifyOrderEac_0AsyncWithHttpInfo($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\VerifyOrderEacResponse'; + $request = $this->verifyOrderEac_0Request($campaign_id, $order_id, $verify_order_eac_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'verifyOrderEac_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function verifyOrderEac_0Request($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling verifyOrderEac_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ExpressApi.verifyOrderEac_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling verifyOrderEac_0' + ); + } + + // verify the required parameter 'verify_order_eac_request' is set + if ($verify_order_eac_request === null || (is_array($verify_order_eac_request) && count($verify_order_eac_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $verify_order_eac_request when calling verifyOrderEac_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/verifyEac'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($verify_order_eac_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($verify_order_eac_request)); + } else { + $httpBody = $verify_order_eac_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/FbsApi.php b/erp24/lib/yandex_market_api/Api/FbsApi.php new file mode 100644 index 00000000..23ddfa7b --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/FbsApi.php @@ -0,0 +1,66259 @@ + [ + 'application/json', + ], + 'addOffersToArchive_2' => [ + 'application/json', + ], + 'calculateTariffs_0' => [ + 'application/json', + ], + 'confirmBusinessPrices_2' => [ + 'application/json', + ], + 'confirmCampaignPrices_2' => [ + 'application/json', + ], + 'confirmShipment_0' => [ + 'application/json', + ], + 'createChat_1' => [ + 'application/json', + ], + 'deleteCampaignOffers_2' => [ + 'application/json', + ], + 'deleteGoodsFeedbackComment_1' => [ + 'application/json', + ], + 'deleteHiddenOffers_1' => [ + 'application/json', + ], + 'deleteOffersFromArchive_2' => [ + 'application/json', + ], + 'deleteOffers_2' => [ + 'application/json', + ], + 'deletePromoOffers_1' => [ + 'application/json', + ], + 'downloadShipmentAct_0' => [ + 'application/json', + ], + 'downloadShipmentDiscrepancyAct_0' => [ + 'application/json', + ], + 'downloadShipmentInboundAct_0' => [ + 'application/json', + ], + 'downloadShipmentPalletLabels_0' => [ + 'application/json', + ], + 'downloadShipmentReceptionTransferAct_0' => [ + 'application/json', + ], + 'downloadShipmentTransportationWaybill_0' => [ + 'application/json', + ], + 'generateBoostConsolidatedReport_1' => [ + 'application/json', + ], + 'generateCompetitorsPositionReport_2' => [ + 'application/json', + ], + 'generateGoodsFeedbackReport_1' => [ + 'application/json', + ], + 'generateGoodsRealizationReport_1' => [ + 'application/json', + ], + 'generateMassOrderLabelsReport_0' => [ + 'application/json', + ], + 'generateOrderLabel_0' => [ + 'application/json', + ], + 'generateOrderLabels_0' => [ + 'application/json', + ], + 'generatePricesReport_1' => [ + 'application/json', + ], + 'generateShelfsStatisticsReport_1' => [ + 'application/json', + ], + 'generateShipmentListDocumentReport_0' => [ + 'application/json', + ], + 'generateShowsSalesReport_2' => [ + 'application/json', + ], + 'generateStocksOnWarehousesReport_1' => [ + 'application/json', + ], + 'generateUnitedMarketplaceServicesReport_2' => [ + 'application/json', + ], + 'generateUnitedNettingReport_2' => [ + 'application/json', + ], + 'generateUnitedOrdersReport_1' => [ + 'application/json', + ], + 'getAllOffers_1' => [ + 'application/json', + ], + 'getBidsInfoForBusiness_1' => [ + 'application/json', + ], + 'getBidsRecommendations_1' => [ + 'application/json', + ], + 'getBusinessQuarantineOffers_2' => [ + 'application/json', + ], + 'getBusinessSettings_1' => [ + 'application/json', + ], + 'getCampaignLogins_2' => [ + 'application/json', + ], + 'getCampaignOffers_2' => [ + 'application/json', + ], + 'getCampaignQuarantineOffers_2' => [ + 'application/json', + ], + 'getCampaignRegion_2' => [ + 'application/json', + ], + 'getCampaignSettings_1' => [ + 'application/json', + ], + 'getCampaign_2' => [ + 'application/json', + ], + 'getCampaignsByLogin_2' => [ + 'application/json', + ], + 'getCampaigns_2' => [ + 'application/json', + ], + 'getCategoriesMaxSaleQuantum_1' => [ + 'application/json', + ], + 'getCategoriesTree_1' => [ + 'application/json', + ], + 'getCategoryContentParameters_2' => [ + 'application/json', + ], + 'getChatHistory_1' => [ + 'application/json', + ], + 'getChats_1' => [ + 'application/json', + ], + 'getDeliveryServices_0' => [ + 'application/json', + ], + 'getFeedIndexLogs_1' => [ + 'application/json', + ], + 'getFeed_1' => [ + 'application/json', + ], + 'getFeedbackAndCommentUpdates_2' => [ + 'application/json', + ], + 'getFeeds_1' => [ + 'application/json', + ], + 'getGoodsFeedbackComments_1' => [ + 'application/json', + ], + 'getGoodsFeedbacks_1' => [ + 'application/json', + ], + 'getGoodsStats_1' => [ + 'application/json', + ], + 'getHiddenOffers_1' => [ + 'application/json', + ], + 'getOfferCardsContentStatus_2' => [ + 'application/json', + ], + 'getOfferMappingEntries_1' => [ + 'application/json', + ], + 'getOfferMappings_2' => [ + 'application/json', + ], + 'getOfferRecommendations_2' => [ + 'application/json', + ], + 'getOffers_1' => [ + 'application/json', + ], + 'getOrderBusinessBuyerInfo_0' => [ + 'application/json', + ], + 'getOrderBusinessDocumentsInfo_0' => [ + 'application/json', + ], + 'getOrderLabelsData_0' => [ + 'application/json', + ], + 'getOrder_1' => [ + 'application/json', + ], + 'getOrdersStats_1' => [ + 'application/json', + ], + 'getOrders_0' => [ + 'application/json', + ], + 'getPricesByOfferIds_1' => [ + 'application/json', + ], + 'getPrices_1' => [ + 'application/json', + ], + 'getPromoOffers_1' => [ + 'application/json', + ], + 'getPromos_1' => [ + 'application/json', + ], + 'getQualityRatingDetails_0' => [ + 'application/json', + ], + 'getQualityRatings_1' => [ + 'application/json', + ], + 'getReportInfo_2' => [ + 'application/json', + ], + 'getReturnApplication_0' => [ + 'application/json', + ], + 'getReturnPhoto_0' => [ + 'application/json', + ], + 'getReturn_0' => [ + 'application/json', + ], + 'getReturns_0' => [ + 'application/json', + ], + 'getShipmentOrdersInfo_0' => [ + 'application/json', + ], + 'getShipment_0' => [ + 'application/json', + ], + 'getStocks_1' => [ + 'application/json', + ], + 'getSuggestedOfferMappingEntries_1' => [ + 'application/json', + ], + 'getSuggestedOfferMappings_2' => [ + 'application/json', + ], + 'getSuggestedPrices_1' => [ + 'application/json', + ], + 'getWarehouses_0' => [ + 'application/json', + ], + 'provideOrderItemIdentifiers_0' => [ + 'application/json', + ], + 'putBidsForBusiness_1' => [ + 'application/json', + ], + 'putBidsForCampaign_1' => [ + 'application/json', + ], + 'refreshFeed_1' => [ + 'application/json', + ], + 'searchRegionChildren_1' => [ + 'application/json', + ], + 'searchRegionsById_1' => [ + 'application/json', + ], + 'searchRegionsByName_1' => [ + 'application/json', + ], + 'searchShipments_0' => [ + 'application/json', + ], + 'sendFileToChat_1' => [ + 'multipart/form-data', + ], + 'sendMessageToChat_1' => [ + 'application/json', + ], + 'setFeedParams_1' => [ + 'application/json', + ], + 'setOrderBoxLayout_0' => [ + 'application/json', + ], + 'setOrderShipmentBoxes_0' => [ + 'application/json', + ], + 'setShipmentPalletsCount_0' => [ + 'application/json', + ], + 'skipGoodsFeedbacksReaction_1' => [ + 'application/json', + ], + 'transferOrdersFromShipment_0' => [ + 'application/json', + ], + 'updateBusinessPrices_1' => [ + 'application/json', + ], + 'updateCampaignOffers_2' => [ + 'application/json', + ], + 'updateGoodsFeedbackComment_1' => [ + 'application/json', + ], + 'updateOfferContent_2' => [ + 'application/json', + ], + 'updateOfferMappingEntries_1' => [ + 'application/json', + ], + 'updateOfferMappings_2' => [ + 'application/json', + ], + 'updateOrderItems_0' => [ + 'application/json', + ], + 'updateOrderStatus_0' => [ + 'application/json', + ], + 'updateOrderStatuses_0' => [ + 'application/json', + ], + 'updatePrices_1' => [ + 'application/json', + ], + 'updatePromoOffers_1' => [ + 'application/json', + ], + 'updateStocks_0' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addHiddenOffers_1 + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addHiddenOffers_1($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_1'][0]) + { + list($response) = $this->addHiddenOffers_1WithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation addHiddenOffers_1WithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addHiddenOffers_1WithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_1'][0]) + { + $request = $this->addHiddenOffers_1Request($campaign_id, $add_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addHiddenOffers_1Async + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffers_1Async($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_1'][0]) + { + return $this->addHiddenOffers_1AsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addHiddenOffers_1AsyncWithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffers_1AsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->addHiddenOffers_1Request($campaign_id, $add_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addHiddenOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addHiddenOffers_1Request($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling addHiddenOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.addHiddenOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_hidden_offers_request' is set + if ($add_hidden_offers_request === null || (is_array($add_hidden_offers_request) && count($add_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_hidden_offers_request when calling addHiddenOffers_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_hidden_offers_request)); + } else { + $httpBody = $add_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation addOffersToArchive_2 + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addOffersToArchive_2($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_2'][0]) + { + list($response) = $this->addOffersToArchive_2WithHttpInfo($business_id, $add_offers_to_archive_request, $contentType); + return $response; + } + + /** + * Operation addOffersToArchive_2WithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addOffersToArchive_2WithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_2'][0]) + { + $request = $this->addOffersToArchive_2Request($business_id, $add_offers_to_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\AddOffersToArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\AddOffersToArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addOffersToArchive_2Async + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchive_2Async($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_2'][0]) + { + return $this->addOffersToArchive_2AsyncWithHttpInfo($business_id, $add_offers_to_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addOffersToArchive_2AsyncWithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchive_2AsyncWithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + $request = $this->addOffersToArchive_2Request($business_id, $add_offers_to_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addOffersToArchive_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addOffersToArchive_2Request($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling addOffersToArchive_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.addOffersToArchive_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_offers_to_archive_request' is set + if ($add_offers_to_archive_request === null || (is_array($add_offers_to_archive_request) && count($add_offers_to_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_offers_to_archive_request when calling addOffersToArchive_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/archive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_offers_to_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_offers_to_archive_request)); + } else { + $httpBody = $add_offers_to_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation calculateTariffs_0 + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function calculateTariffs_0($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_0'][0]) + { + list($response) = $this->calculateTariffs_0WithHttpInfo($calculate_tariffs_request, $contentType); + return $response; + } + + /** + * Operation calculateTariffs_0WithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function calculateTariffs_0WithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_0'][0]) + { + $request = $this->calculateTariffs_0Request($calculate_tariffs_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CalculateTariffsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CalculateTariffsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation calculateTariffs_0Async + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffs_0Async($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_0'][0]) + { + return $this->calculateTariffs_0AsyncWithHttpInfo($calculate_tariffs_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation calculateTariffs_0AsyncWithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffs_0AsyncWithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + $request = $this->calculateTariffs_0Request($calculate_tariffs_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'calculateTariffs_0' + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function calculateTariffs_0Request($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_0'][0]) + { + + // verify the required parameter 'calculate_tariffs_request' is set + if ($calculate_tariffs_request === null || (is_array($calculate_tariffs_request) && count($calculate_tariffs_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $calculate_tariffs_request when calling calculateTariffs_0' + ); + } + + + $resourcePath = '/tariffs/calculate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($calculate_tariffs_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($calculate_tariffs_request)); + } else { + $httpBody = $calculate_tariffs_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmBusinessPrices_2 + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmBusinessPrices_2($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_2'][0]) + { + list($response) = $this->confirmBusinessPrices_2WithHttpInfo($business_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmBusinessPrices_2WithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmBusinessPrices_2WithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_2'][0]) + { + $request = $this->confirmBusinessPrices_2Request($business_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmBusinessPrices_2Async + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPrices_2Async($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_2'][0]) + { + return $this->confirmBusinessPrices_2AsyncWithHttpInfo($business_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmBusinessPrices_2AsyncWithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPrices_2AsyncWithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmBusinessPrices_2Request($business_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmBusinessPrices_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmBusinessPrices_2Request($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling confirmBusinessPrices_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.confirmBusinessPrices_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmBusinessPrices_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmCampaignPrices_2 + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmCampaignPrices_2($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_2'][0]) + { + list($response) = $this->confirmCampaignPrices_2WithHttpInfo($campaign_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmCampaignPrices_2WithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmCampaignPrices_2WithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_2'][0]) + { + $request = $this->confirmCampaignPrices_2Request($campaign_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmCampaignPrices_2Async + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPrices_2Async($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_2'][0]) + { + return $this->confirmCampaignPrices_2AsyncWithHttpInfo($campaign_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmCampaignPrices_2AsyncWithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPrices_2AsyncWithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmCampaignPrices_2Request($campaign_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmCampaignPrices_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmCampaignPrices_2Request($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling confirmCampaignPrices_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.confirmCampaignPrices_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmCampaignPrices_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmShipment_0 + * + * Подтверждение отгрузки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmShipment_0($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment_0'][0]) + { + list($response) = $this->confirmShipment_0WithHttpInfo($campaign_id, $shipment_id, $confirm_shipment_request, $contentType); + return $response; + } + + /** + * Operation confirmShipment_0WithHttpInfo + * + * Подтверждение отгрузки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmShipment_0WithHttpInfo($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment_0'][0]) + { + $request = $this->confirmShipment_0Request($campaign_id, $shipment_id, $confirm_shipment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmShipment_0Async + * + * Подтверждение отгрузки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmShipment_0Async($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment_0'][0]) + { + return $this->confirmShipment_0AsyncWithHttpInfo($campaign_id, $shipment_id, $confirm_shipment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmShipment_0AsyncWithHttpInfo + * + * Подтверждение отгрузки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmShipment_0AsyncWithHttpInfo($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmShipment_0Request($campaign_id, $shipment_id, $confirm_shipment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmShipment_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmShipment_0Request($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling confirmShipment_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.confirmShipment_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling confirmShipment_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.confirmShipment_0, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_shipment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_shipment_request)); + } else { + $httpBody = $confirm_shipment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation createChat_1 + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function createChat_1($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_1'][0]) + { + list($response) = $this->createChat_1WithHttpInfo($business_id, $create_chat_request, $contentType); + return $response; + } + + /** + * Operation createChat_1WithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function createChat_1WithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_1'][0]) + { + $request = $this->createChat_1Request($business_id, $create_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CreateChatResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CreateChatResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CreateChatResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CreateChatResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createChat_1Async + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChat_1Async($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_1'][0]) + { + return $this->createChat_1AsyncWithHttpInfo($business_id, $create_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createChat_1AsyncWithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChat_1AsyncWithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + $request = $this->createChat_1Request($business_id, $create_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createChat_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createChat_1Request($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling createChat_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.createChat_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'create_chat_request' is set + if ($create_chat_request === null || (is_array($create_chat_request) && count($create_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $create_chat_request when calling createChat_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/new'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($create_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($create_chat_request)); + } else { + $httpBody = $create_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteCampaignOffers_2 + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteCampaignOffers_2($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_2'][0]) + { + list($response) = $this->deleteCampaignOffers_2WithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteCampaignOffers_2WithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteCampaignOffers_2WithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_2'][0]) + { + $request = $this->deleteCampaignOffers_2Request($campaign_id, $delete_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteCampaignOffers_2Async + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffers_2Async($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_2'][0]) + { + return $this->deleteCampaignOffers_2AsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteCampaignOffers_2AsyncWithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffers_2AsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + $request = $this->deleteCampaignOffers_2Request($campaign_id, $delete_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteCampaignOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteCampaignOffers_2Request($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteCampaignOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.deleteCampaignOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_campaign_offers_request' is set + if ($delete_campaign_offers_request === null || (is_array($delete_campaign_offers_request) && count($delete_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_campaign_offers_request when calling deleteCampaignOffers_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_campaign_offers_request)); + } else { + $httpBody = $delete_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteGoodsFeedbackComment_1 + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteGoodsFeedbackComment_1($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_1'][0]) + { + list($response) = $this->deleteGoodsFeedbackComment_1WithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation deleteGoodsFeedbackComment_1WithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteGoodsFeedbackComment_1WithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_1'][0]) + { + $request = $this->deleteGoodsFeedbackComment_1Request($business_id, $delete_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteGoodsFeedbackComment_1Async + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackComment_1Async($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_1'][0]) + { + return $this->deleteGoodsFeedbackComment_1AsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteGoodsFeedbackComment_1AsyncWithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackComment_1AsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteGoodsFeedbackComment_1Request($business_id, $delete_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteGoodsFeedbackComment_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteGoodsFeedbackComment_1Request($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteGoodsFeedbackComment_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.deleteGoodsFeedbackComment_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_goods_feedback_comment_request' is set + if ($delete_goods_feedback_comment_request === null || (is_array($delete_goods_feedback_comment_request) && count($delete_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_goods_feedback_comment_request when calling deleteGoodsFeedbackComment_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_goods_feedback_comment_request)); + } else { + $httpBody = $delete_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteHiddenOffers_1 + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteHiddenOffers_1($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_1'][0]) + { + list($response) = $this->deleteHiddenOffers_1WithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteHiddenOffers_1WithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteHiddenOffers_1WithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_1'][0]) + { + $request = $this->deleteHiddenOffers_1Request($campaign_id, $delete_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteHiddenOffers_1Async + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffers_1Async($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_1'][0]) + { + return $this->deleteHiddenOffers_1AsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteHiddenOffers_1AsyncWithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffers_1AsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteHiddenOffers_1Request($campaign_id, $delete_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteHiddenOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteHiddenOffers_1Request($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteHiddenOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.deleteHiddenOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_hidden_offers_request' is set + if ($delete_hidden_offers_request === null || (is_array($delete_hidden_offers_request) && count($delete_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_hidden_offers_request when calling deleteHiddenOffers_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_hidden_offers_request)); + } else { + $httpBody = $delete_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffersFromArchive_2 + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffersFromArchive_2($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_2'][0]) + { + list($response) = $this->deleteOffersFromArchive_2WithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType); + return $response; + } + + /** + * Operation deleteOffersFromArchive_2WithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffersFromArchive_2WithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_2'][0]) + { + $request = $this->deleteOffersFromArchive_2Request($business_id, $delete_offers_from_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffersFromArchive_2Async + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchive_2Async($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_2'][0]) + { + return $this->deleteOffersFromArchive_2AsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffersFromArchive_2AsyncWithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchive_2AsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + $request = $this->deleteOffersFromArchive_2Request($business_id, $delete_offers_from_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffersFromArchive_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffersFromArchive_2Request($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffersFromArchive_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.deleteOffersFromArchive_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_from_archive_request' is set + if ($delete_offers_from_archive_request === null || (is_array($delete_offers_from_archive_request) && count($delete_offers_from_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_from_archive_request when calling deleteOffersFromArchive_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/unarchive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_from_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_from_archive_request)); + } else { + $httpBody = $delete_offers_from_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffers_2 + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffers_2($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_2'][0]) + { + list($response) = $this->deleteOffers_2WithHttpInfo($business_id, $delete_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteOffers_2WithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffers_2WithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_2'][0]) + { + $request = $this->deleteOffers_2Request($business_id, $delete_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffers_2Async + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffers_2Async($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_2'][0]) + { + return $this->deleteOffers_2AsyncWithHttpInfo($business_id, $delete_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffers_2AsyncWithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffers_2AsyncWithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + $request = $this->deleteOffers_2Request($business_id, $delete_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffers_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffers_2Request($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffers_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.deleteOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_request' is set + if ($delete_offers_request === null || (is_array($delete_offers_request) && count($delete_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_request when calling deleteOffers_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_request)); + } else { + $httpBody = $delete_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deletePromoOffers_1 + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deletePromoOffers_1($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_1'][0]) + { + list($response) = $this->deletePromoOffers_1WithHttpInfo($business_id, $delete_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation deletePromoOffers_1WithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deletePromoOffers_1WithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_1'][0]) + { + $request = $this->deletePromoOffers_1Request($business_id, $delete_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeletePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeletePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deletePromoOffers_1Async + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffers_1Async($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_1'][0]) + { + return $this->deletePromoOffers_1AsyncWithHttpInfo($business_id, $delete_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deletePromoOffers_1AsyncWithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffers_1AsyncWithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + $request = $this->deletePromoOffers_1Request($business_id, $delete_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePromoOffers_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deletePromoOffers_1Request($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deletePromoOffers_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.deletePromoOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_promo_offers_request' is set + if ($delete_promo_offers_request === null || (is_array($delete_promo_offers_request) && count($delete_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_promo_offers_request when calling deletePromoOffers_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_promo_offers_request)); + } else { + $httpBody = $delete_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentAct_0 + * + * Получение акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentAct_0($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct_0'][0]) + { + list($response) = $this->downloadShipmentAct_0WithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentAct_0WithHttpInfo + * + * Получение акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentAct_0WithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct_0'][0]) + { + $request = $this->downloadShipmentAct_0Request($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentAct_0Async + * + * Получение акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentAct_0Async($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct_0'][0]) + { + return $this->downloadShipmentAct_0AsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentAct_0AsyncWithHttpInfo + * + * Получение акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentAct_0AsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentAct_0Request($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentAct_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentAct_0Request($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentAct_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.downloadShipmentAct_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentAct_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.downloadShipmentAct_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/act'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentDiscrepancyAct_0 + * + * Получение акта расхождений + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentDiscrepancyAct_0($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct_0'][0]) + { + list($response) = $this->downloadShipmentDiscrepancyAct_0WithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentDiscrepancyAct_0WithHttpInfo + * + * Получение акта расхождений + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentDiscrepancyAct_0WithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct_0'][0]) + { + $request = $this->downloadShipmentDiscrepancyAct_0Request($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentDiscrepancyAct_0Async + * + * Получение акта расхождений + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentDiscrepancyAct_0Async($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct_0'][0]) + { + return $this->downloadShipmentDiscrepancyAct_0AsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentDiscrepancyAct_0AsyncWithHttpInfo + * + * Получение акта расхождений + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentDiscrepancyAct_0AsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentDiscrepancyAct_0Request($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentDiscrepancyAct_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentDiscrepancyAct_0Request($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentDiscrepancyAct_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.downloadShipmentDiscrepancyAct_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentDiscrepancyAct_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.downloadShipmentDiscrepancyAct_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/discrepancy-act'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/vnd.ms-excel', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentInboundAct_0 + * + * Получение фактического акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentInboundAct_0($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct_0'][0]) + { + list($response) = $this->downloadShipmentInboundAct_0WithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentInboundAct_0WithHttpInfo + * + * Получение фактического акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentInboundAct_0WithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct_0'][0]) + { + $request = $this->downloadShipmentInboundAct_0Request($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentInboundAct_0Async + * + * Получение фактического акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentInboundAct_0Async($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct_0'][0]) + { + return $this->downloadShipmentInboundAct_0AsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentInboundAct_0AsyncWithHttpInfo + * + * Получение фактического акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentInboundAct_0AsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentInboundAct_0Request($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentInboundAct_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentInboundAct_0Request($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentInboundAct_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.downloadShipmentInboundAct_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentInboundAct_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.downloadShipmentInboundAct_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/inbound-act'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentPalletLabels_0 + * + * Ярлыки для доверительной приемки (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentPalletLabels_0($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels_0'][0]) + { + list($response) = $this->downloadShipmentPalletLabels_0WithHttpInfo($campaign_id, $shipment_id, $format, $contentType); + return $response; + } + + /** + * Operation downloadShipmentPalletLabels_0WithHttpInfo + * + * Ярлыки для доверительной приемки (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentPalletLabels_0WithHttpInfo($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels_0'][0]) + { + $request = $this->downloadShipmentPalletLabels_0Request($campaign_id, $shipment_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentPalletLabels_0Async + * + * Ярлыки для доверительной приемки (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentPalletLabels_0Async($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels_0'][0]) + { + return $this->downloadShipmentPalletLabels_0AsyncWithHttpInfo($campaign_id, $shipment_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentPalletLabels_0AsyncWithHttpInfo + * + * Ярлыки для доверительной приемки (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentPalletLabels_0AsyncWithHttpInfo($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentPalletLabels_0Request($campaign_id, $shipment_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentPalletLabels_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentPalletLabels_0Request($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentPalletLabels_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.downloadShipmentPalletLabels_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentPalletLabels_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.downloadShipmentPalletLabels_0, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/pallet/labels'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ShipmentPalletLabelPageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentReceptionTransferAct_0 + * + * Подтверждение ближайшей отгрузки и получение акта приема-передачи для нее + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentReceptionTransferAct_0($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct_0'][0]) + { + list($response) = $this->downloadShipmentReceptionTransferAct_0WithHttpInfo($campaign_id, $warehouse_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentReceptionTransferAct_0WithHttpInfo + * + * Подтверждение ближайшей отгрузки и получение акта приема-передачи для нее + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentReceptionTransferAct_0WithHttpInfo($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct_0'][0]) + { + $request = $this->downloadShipmentReceptionTransferAct_0Request($campaign_id, $warehouse_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentReceptionTransferAct_0Async + * + * Подтверждение ближайшей отгрузки и получение акта приема-передачи для нее + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentReceptionTransferAct_0Async($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct_0'][0]) + { + return $this->downloadShipmentReceptionTransferAct_0AsyncWithHttpInfo($campaign_id, $warehouse_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentReceptionTransferAct_0AsyncWithHttpInfo + * + * Подтверждение ближайшей отгрузки и получение акта приема-передачи для нее + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentReceptionTransferAct_0AsyncWithHttpInfo($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentReceptionTransferAct_0Request($campaign_id, $warehouse_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentReceptionTransferAct_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentReceptionTransferAct_0Request($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentReceptionTransferAct_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.downloadShipmentReceptionTransferAct_0, must be bigger than or equal to 1.'); + } + + if ($warehouse_id !== null && $warehouse_id < 1) { + throw new \InvalidArgumentException('invalid value for "$warehouse_id" when calling FbsApi.downloadShipmentReceptionTransferAct_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/shipments/reception-transfer-act'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $warehouse_id, + 'warehouse_id', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentTransportationWaybill_0 + * + * Получение транспортной накладной + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentTransportationWaybill_0($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill_0'][0]) + { + list($response) = $this->downloadShipmentTransportationWaybill_0WithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentTransportationWaybill_0WithHttpInfo + * + * Получение транспортной накладной + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentTransportationWaybill_0WithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill_0'][0]) + { + $request = $this->downloadShipmentTransportationWaybill_0Request($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentTransportationWaybill_0Async + * + * Получение транспортной накладной + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentTransportationWaybill_0Async($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill_0'][0]) + { + return $this->downloadShipmentTransportationWaybill_0AsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentTransportationWaybill_0AsyncWithHttpInfo + * + * Получение транспортной накладной + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentTransportationWaybill_0AsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentTransportationWaybill_0Request($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentTransportationWaybill_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentTransportationWaybill_0Request($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentTransportationWaybill_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.downloadShipmentTransportationWaybill_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentTransportationWaybill_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.downloadShipmentTransportationWaybill_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/transportation-waybill'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/vnd.ms-excel', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateBoostConsolidatedReport_1 + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateBoostConsolidatedReport_1($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_1'][0]) + { + list($response) = $this->generateBoostConsolidatedReport_1WithHttpInfo($generate_boost_consolidated_request, $format, $contentType); + return $response; + } + + /** + * Operation generateBoostConsolidatedReport_1WithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateBoostConsolidatedReport_1WithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_1'][0]) + { + $request = $this->generateBoostConsolidatedReport_1Request($generate_boost_consolidated_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateBoostConsolidatedReport_1Async + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReport_1Async($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_1'][0]) + { + return $this->generateBoostConsolidatedReport_1AsyncWithHttpInfo($generate_boost_consolidated_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateBoostConsolidatedReport_1AsyncWithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReport_1AsyncWithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateBoostConsolidatedReport_1Request($generate_boost_consolidated_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateBoostConsolidatedReport_1' + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateBoostConsolidatedReport_1Request($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_1'][0]) + { + + // verify the required parameter 'generate_boost_consolidated_request' is set + if ($generate_boost_consolidated_request === null || (is_array($generate_boost_consolidated_request) && count($generate_boost_consolidated_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_boost_consolidated_request when calling generateBoostConsolidatedReport_1' + ); + } + + + + $resourcePath = '/reports/boost-consolidated/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_boost_consolidated_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_boost_consolidated_request)); + } else { + $httpBody = $generate_boost_consolidated_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateCompetitorsPositionReport_2 + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateCompetitorsPositionReport_2($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_2'][0]) + { + list($response) = $this->generateCompetitorsPositionReport_2WithHttpInfo($generate_competitors_position_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateCompetitorsPositionReport_2WithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateCompetitorsPositionReport_2WithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_2'][0]) + { + $request = $this->generateCompetitorsPositionReport_2Request($generate_competitors_position_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateCompetitorsPositionReport_2Async + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReport_2Async($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_2'][0]) + { + return $this->generateCompetitorsPositionReport_2AsyncWithHttpInfo($generate_competitors_position_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateCompetitorsPositionReport_2AsyncWithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReport_2AsyncWithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateCompetitorsPositionReport_2Request($generate_competitors_position_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateCompetitorsPositionReport_2' + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateCompetitorsPositionReport_2Request($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_2'][0]) + { + + // verify the required parameter 'generate_competitors_position_report_request' is set + if ($generate_competitors_position_report_request === null || (is_array($generate_competitors_position_report_request) && count($generate_competitors_position_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_competitors_position_report_request when calling generateCompetitorsPositionReport_2' + ); + } + + + + $resourcePath = '/reports/competitors-position/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_competitors_position_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_competitors_position_report_request)); + } else { + $httpBody = $generate_competitors_position_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsFeedbackReport_1 + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsFeedbackReport_1($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_1'][0]) + { + list($response) = $this->generateGoodsFeedbackReport_1WithHttpInfo($generate_goods_feedback_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsFeedbackReport_1WithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsFeedbackReport_1WithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_1'][0]) + { + $request = $this->generateGoodsFeedbackReport_1Request($generate_goods_feedback_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsFeedbackReport_1Async + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReport_1Async($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_1'][0]) + { + return $this->generateGoodsFeedbackReport_1AsyncWithHttpInfo($generate_goods_feedback_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsFeedbackReport_1AsyncWithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReport_1AsyncWithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsFeedbackReport_1Request($generate_goods_feedback_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsFeedbackReport_1' + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsFeedbackReport_1Request($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_1'][0]) + { + + // verify the required parameter 'generate_goods_feedback_request' is set + if ($generate_goods_feedback_request === null || (is_array($generate_goods_feedback_request) && count($generate_goods_feedback_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_feedback_request when calling generateGoodsFeedbackReport_1' + ); + } + + + + $resourcePath = '/reports/goods-feedback/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_feedback_request)); + } else { + $httpBody = $generate_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsRealizationReport_1 + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsRealizationReport_1($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_1'][0]) + { + list($response) = $this->generateGoodsRealizationReport_1WithHttpInfo($generate_goods_realization_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsRealizationReport_1WithHttpInfo + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsRealizationReport_1WithHttpInfo($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_1'][0]) + { + $request = $this->generateGoodsRealizationReport_1Request($generate_goods_realization_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsRealizationReport_1Async + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsRealizationReport_1Async($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_1'][0]) + { + return $this->generateGoodsRealizationReport_1AsyncWithHttpInfo($generate_goods_realization_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsRealizationReport_1AsyncWithHttpInfo + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsRealizationReport_1AsyncWithHttpInfo($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsRealizationReport_1Request($generate_goods_realization_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsRealizationReport_1' + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsRealizationReport_1Request($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_1'][0]) + { + + // verify the required parameter 'generate_goods_realization_report_request' is set + if ($generate_goods_realization_report_request === null || (is_array($generate_goods_realization_report_request) && count($generate_goods_realization_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_realization_report_request when calling generateGoodsRealizationReport_1' + ); + } + + + + $resourcePath = '/reports/goods-realization/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_realization_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_realization_report_request)); + } else { + $httpBody = $generate_goods_realization_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateMassOrderLabelsReport_0 + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateMassOrderLabelsReport_0($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_0'][0]) + { + list($response) = $this->generateMassOrderLabelsReport_0WithHttpInfo($generate_mass_order_labels_request, $format, $contentType); + return $response; + } + + /** + * Operation generateMassOrderLabelsReport_0WithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateMassOrderLabelsReport_0WithHttpInfo($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_0'][0]) + { + $request = $this->generateMassOrderLabelsReport_0Request($generate_mass_order_labels_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateMassOrderLabelsReport_0Async + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateMassOrderLabelsReport_0Async($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_0'][0]) + { + return $this->generateMassOrderLabelsReport_0AsyncWithHttpInfo($generate_mass_order_labels_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateMassOrderLabelsReport_0AsyncWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateMassOrderLabelsReport_0AsyncWithHttpInfo($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateMassOrderLabelsReport_0Request($generate_mass_order_labels_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateMassOrderLabelsReport_0' + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateMassOrderLabelsReport_0Request($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport_0'][0]) + { + + // verify the required parameter 'generate_mass_order_labels_request' is set + if ($generate_mass_order_labels_request === null || (is_array($generate_mass_order_labels_request) && count($generate_mass_order_labels_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_mass_order_labels_request when calling generateMassOrderLabelsReport_0' + ); + } + + + + $resourcePath = '/reports/documents/labels/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_mass_order_labels_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_mass_order_labels_request)); + } else { + $httpBody = $generate_mass_order_labels_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateOrderLabel_0 + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateOrderLabel_0($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_0'][0]) + { + list($response) = $this->generateOrderLabel_0WithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + return $response; + } + + /** + * Operation generateOrderLabel_0WithHttpInfo + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateOrderLabel_0WithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_0'][0]) + { + $request = $this->generateOrderLabel_0Request($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateOrderLabel_0Async + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabel_0Async($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_0'][0]) + { + return $this->generateOrderLabel_0AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateOrderLabel_0AsyncWithHttpInfo + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabel_0AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->generateOrderLabel_0Request($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateOrderLabel_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateOrderLabel_0Request($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling generateOrderLabel_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.generateOrderLabel_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling generateOrderLabel_0' + ); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling generateOrderLabel_0' + ); + } + + // verify the required parameter 'box_id' is set + if ($box_id === null || (is_array($box_id) && count($box_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $box_id when calling generateOrderLabel_0' + ); + } + + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes/{boxId}/label'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + // path params + if ($box_id !== null) { + $resourcePath = str_replace( + '{' . 'boxId' . '}', + ObjectSerializer::toPathValue($box_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateOrderLabels_0 + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateOrderLabels_0($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_0'][0]) + { + list($response) = $this->generateOrderLabels_0WithHttpInfo($campaign_id, $order_id, $format, $contentType); + return $response; + } + + /** + * Operation generateOrderLabels_0WithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateOrderLabels_0WithHttpInfo($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_0'][0]) + { + $request = $this->generateOrderLabels_0Request($campaign_id, $order_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateOrderLabels_0Async + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabels_0Async($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_0'][0]) + { + return $this->generateOrderLabels_0AsyncWithHttpInfo($campaign_id, $order_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateOrderLabels_0AsyncWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabels_0AsyncWithHttpInfo($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->generateOrderLabels_0Request($campaign_id, $order_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateOrderLabels_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateOrderLabels_0Request($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling generateOrderLabels_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.generateOrderLabels_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling generateOrderLabels_0' + ); + } + + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/labels'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generatePricesReport_1 + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generatePricesReport_1($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_1'][0]) + { + list($response) = $this->generatePricesReport_1WithHttpInfo($generate_prices_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generatePricesReport_1WithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generatePricesReport_1WithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_1'][0]) + { + $request = $this->generatePricesReport_1Request($generate_prices_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generatePricesReport_1Async + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReport_1Async($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_1'][0]) + { + return $this->generatePricesReport_1AsyncWithHttpInfo($generate_prices_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generatePricesReport_1AsyncWithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReport_1AsyncWithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generatePricesReport_1Request($generate_prices_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generatePricesReport_1' + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generatePricesReport_1Request($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_1'][0]) + { + + // verify the required parameter 'generate_prices_report_request' is set + if ($generate_prices_report_request === null || (is_array($generate_prices_report_request) && count($generate_prices_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_prices_report_request when calling generatePricesReport_1' + ); + } + + + + $resourcePath = '/reports/prices/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_prices_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_prices_report_request)); + } else { + $httpBody = $generate_prices_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShelfsStatisticsReport_1 + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShelfsStatisticsReport_1($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_1'][0]) + { + list($response) = $this->generateShelfsStatisticsReport_1WithHttpInfo($generate_shelfs_statistics_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShelfsStatisticsReport_1WithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShelfsStatisticsReport_1WithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_1'][0]) + { + $request = $this->generateShelfsStatisticsReport_1Request($generate_shelfs_statistics_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShelfsStatisticsReport_1Async + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReport_1Async($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_1'][0]) + { + return $this->generateShelfsStatisticsReport_1AsyncWithHttpInfo($generate_shelfs_statistics_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShelfsStatisticsReport_1AsyncWithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReport_1AsyncWithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShelfsStatisticsReport_1Request($generate_shelfs_statistics_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShelfsStatisticsReport_1' + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShelfsStatisticsReport_1Request($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_1'][0]) + { + + // verify the required parameter 'generate_shelfs_statistics_request' is set + if ($generate_shelfs_statistics_request === null || (is_array($generate_shelfs_statistics_request) && count($generate_shelfs_statistics_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shelfs_statistics_request when calling generateShelfsStatisticsReport_1' + ); + } + + + + $resourcePath = '/reports/shelf-statistics/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shelfs_statistics_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shelfs_statistics_request)); + } else { + $httpBody = $generate_shelfs_statistics_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShipmentListDocumentReport_0 + * + * Получение листа сборки + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShipmentListDocumentReport_0($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport_0'][0]) + { + list($response) = $this->generateShipmentListDocumentReport_0WithHttpInfo($generate_shipment_list_document_report_request, $contentType); + return $response; + } + + /** + * Operation generateShipmentListDocumentReport_0WithHttpInfo + * + * Получение листа сборки + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShipmentListDocumentReport_0WithHttpInfo($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport_0'][0]) + { + $request = $this->generateShipmentListDocumentReport_0Request($generate_shipment_list_document_report_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShipmentListDocumentReport_0Async + * + * Получение листа сборки + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShipmentListDocumentReport_0Async($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport_0'][0]) + { + return $this->generateShipmentListDocumentReport_0AsyncWithHttpInfo($generate_shipment_list_document_report_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShipmentListDocumentReport_0AsyncWithHttpInfo + * + * Получение листа сборки + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShipmentListDocumentReport_0AsyncWithHttpInfo($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShipmentListDocumentReport_0Request($generate_shipment_list_document_report_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShipmentListDocumentReport_0' + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShipmentListDocumentReport_0Request($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport_0'][0]) + { + + // verify the required parameter 'generate_shipment_list_document_report_request' is set + if ($generate_shipment_list_document_report_request === null || (is_array($generate_shipment_list_document_report_request) && count($generate_shipment_list_document_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shipment_list_document_report_request when calling generateShipmentListDocumentReport_0' + ); + } + + + $resourcePath = '/reports/documents/shipment-list/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shipment_list_document_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shipment_list_document_report_request)); + } else { + $httpBody = $generate_shipment_list_document_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShowsSalesReport_2 + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShowsSalesReport_2($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_2'][0]) + { + list($response) = $this->generateShowsSalesReport_2WithHttpInfo($generate_shows_sales_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShowsSalesReport_2WithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShowsSalesReport_2WithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_2'][0]) + { + $request = $this->generateShowsSalesReport_2Request($generate_shows_sales_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShowsSalesReport_2Async + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReport_2Async($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_2'][0]) + { + return $this->generateShowsSalesReport_2AsyncWithHttpInfo($generate_shows_sales_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShowsSalesReport_2AsyncWithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReport_2AsyncWithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShowsSalesReport_2Request($generate_shows_sales_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShowsSalesReport_2' + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShowsSalesReport_2Request($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_2'][0]) + { + + // verify the required parameter 'generate_shows_sales_report_request' is set + if ($generate_shows_sales_report_request === null || (is_array($generate_shows_sales_report_request) && count($generate_shows_sales_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shows_sales_report_request when calling generateShowsSalesReport_2' + ); + } + + + + $resourcePath = '/reports/shows-sales/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shows_sales_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shows_sales_report_request)); + } else { + $httpBody = $generate_shows_sales_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateStocksOnWarehousesReport_1 + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateStocksOnWarehousesReport_1($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_1'][0]) + { + list($response) = $this->generateStocksOnWarehousesReport_1WithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateStocksOnWarehousesReport_1WithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateStocksOnWarehousesReport_1WithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_1'][0]) + { + $request = $this->generateStocksOnWarehousesReport_1Request($generate_stocks_on_warehouses_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateStocksOnWarehousesReport_1Async + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReport_1Async($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_1'][0]) + { + return $this->generateStocksOnWarehousesReport_1AsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateStocksOnWarehousesReport_1AsyncWithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReport_1AsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateStocksOnWarehousesReport_1Request($generate_stocks_on_warehouses_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateStocksOnWarehousesReport_1' + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateStocksOnWarehousesReport_1Request($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_1'][0]) + { + + // verify the required parameter 'generate_stocks_on_warehouses_report_request' is set + if ($generate_stocks_on_warehouses_report_request === null || (is_array($generate_stocks_on_warehouses_report_request) && count($generate_stocks_on_warehouses_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_stocks_on_warehouses_report_request when calling generateStocksOnWarehousesReport_1' + ); + } + + + + $resourcePath = '/reports/stocks-on-warehouses/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_stocks_on_warehouses_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_stocks_on_warehouses_report_request)); + } else { + $httpBody = $generate_stocks_on_warehouses_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport_2 + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedMarketplaceServicesReport_2($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_2'][0]) + { + list($response) = $this->generateUnitedMarketplaceServicesReport_2WithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedMarketplaceServicesReport_2WithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedMarketplaceServicesReport_2WithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_2'][0]) + { + $request = $this->generateUnitedMarketplaceServicesReport_2Request($generate_united_marketplace_services_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedMarketplaceServicesReport_2Async + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReport_2Async($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_2'][0]) + { + return $this->generateUnitedMarketplaceServicesReport_2AsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport_2AsyncWithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReport_2AsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedMarketplaceServicesReport_2Request($generate_united_marketplace_services_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedMarketplaceServicesReport_2' + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedMarketplaceServicesReport_2Request($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_2'][0]) + { + + // verify the required parameter 'generate_united_marketplace_services_report_request' is set + if ($generate_united_marketplace_services_report_request === null || (is_array($generate_united_marketplace_services_report_request) && count($generate_united_marketplace_services_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_marketplace_services_report_request when calling generateUnitedMarketplaceServicesReport_2' + ); + } + + + + $resourcePath = '/reports/united-marketplace-services/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_marketplace_services_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_marketplace_services_report_request)); + } else { + $httpBody = $generate_united_marketplace_services_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedNettingReport_2 + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedNettingReport_2($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_2'][0]) + { + list($response) = $this->generateUnitedNettingReport_2WithHttpInfo($generate_united_netting_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedNettingReport_2WithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedNettingReport_2WithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_2'][0]) + { + $request = $this->generateUnitedNettingReport_2Request($generate_united_netting_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedNettingReport_2Async + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReport_2Async($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_2'][0]) + { + return $this->generateUnitedNettingReport_2AsyncWithHttpInfo($generate_united_netting_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedNettingReport_2AsyncWithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReport_2AsyncWithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedNettingReport_2Request($generate_united_netting_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedNettingReport_2' + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedNettingReport_2Request($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_2'][0]) + { + + // verify the required parameter 'generate_united_netting_report_request' is set + if ($generate_united_netting_report_request === null || (is_array($generate_united_netting_report_request) && count($generate_united_netting_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_netting_report_request when calling generateUnitedNettingReport_2' + ); + } + + + + $resourcePath = '/reports/united-netting/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_netting_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_netting_report_request)); + } else { + $httpBody = $generate_united_netting_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedOrdersReport_1 + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedOrdersReport_1($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_1'][0]) + { + list($response) = $this->generateUnitedOrdersReport_1WithHttpInfo($generate_united_orders_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedOrdersReport_1WithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedOrdersReport_1WithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_1'][0]) + { + $request = $this->generateUnitedOrdersReport_1Request($generate_united_orders_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedOrdersReport_1Async + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReport_1Async($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_1'][0]) + { + return $this->generateUnitedOrdersReport_1AsyncWithHttpInfo($generate_united_orders_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedOrdersReport_1AsyncWithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReport_1AsyncWithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedOrdersReport_1Request($generate_united_orders_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedOrdersReport_1' + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedOrdersReport_1Request($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_1'][0]) + { + + // verify the required parameter 'generate_united_orders_request' is set + if ($generate_united_orders_request === null || (is_array($generate_united_orders_request) && count($generate_united_orders_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_orders_request when calling generateUnitedOrdersReport_1' + ); + } + + + + $resourcePath = '/reports/united-orders/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_orders_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_orders_request)); + } else { + $httpBody = $generate_united_orders_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getAllOffers_1 + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getAllOffers_1($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_1'][0]) + { + list($response) = $this->getAllOffers_1WithHttpInfo($campaign_id, $feed_id, $chunk, $contentType); + return $response; + } + + /** + * Operation getAllOffers_1WithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getAllOffers_1WithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_1'][0]) + { + $request = $this->getAllOffers_1Request($campaign_id, $feed_id, $chunk, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetAllOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetAllOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetAllOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetAllOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getAllOffers_1Async + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffers_1Async($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_1'][0]) + { + return $this->getAllOffers_1AsyncWithHttpInfo($campaign_id, $feed_id, $chunk, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getAllOffers_1AsyncWithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffers_1AsyncWithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + $request = $this->getAllOffers_1Request($campaign_id, $feed_id, $chunk, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getAllOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getAllOffers_1Request($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getAllOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getAllOffers_1, must be bigger than or equal to 1.'); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers/all'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chunk, + 'chunk', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsInfoForBusiness_1 + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsInfoForBusiness_1($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_1'][0]) + { + list($response) = $this->getBidsInfoForBusiness_1WithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + return $response; + } + + /** + * Operation getBidsInfoForBusiness_1WithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsInfoForBusiness_1WithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_1'][0]) + { + $request = $this->getBidsInfoForBusiness_1Request($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsInfoForBusiness_1Async + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusiness_1Async($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_1'][0]) + { + return $this->getBidsInfoForBusiness_1AsyncWithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsInfoForBusiness_1AsyncWithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusiness_1AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + $request = $this->getBidsInfoForBusiness_1Request($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsInfoForBusiness_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsInfoForBusiness_1Request($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsInfoForBusiness_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getBidsInfoForBusiness_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/bids/info'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_info_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_info_request)); + } else { + $httpBody = $get_bids_info_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsRecommendations_1 + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsRecommendations_1($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_1'][0]) + { + list($response) = $this->getBidsRecommendations_1WithHttpInfo($business_id, $get_bids_recommendations_request, $contentType); + return $response; + } + + /** + * Operation getBidsRecommendations_1WithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsRecommendations_1WithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_1'][0]) + { + $request = $this->getBidsRecommendations_1Request($business_id, $get_bids_recommendations_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsRecommendations_1Async + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendations_1Async($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_1'][0]) + { + return $this->getBidsRecommendations_1AsyncWithHttpInfo($business_id, $get_bids_recommendations_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsRecommendations_1AsyncWithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendations_1AsyncWithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + $request = $this->getBidsRecommendations_1Request($business_id, $get_bids_recommendations_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsRecommendations_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsRecommendations_1Request($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsRecommendations_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getBidsRecommendations_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_bids_recommendations_request' is set + if ($get_bids_recommendations_request === null || (is_array($get_bids_recommendations_request) && count($get_bids_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_bids_recommendations_request when calling getBidsRecommendations_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_recommendations_request)); + } else { + $httpBody = $get_bids_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessQuarantineOffers_2 + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessQuarantineOffers_2($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_2'][0]) + { + list($response) = $this->getBusinessQuarantineOffers_2WithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getBusinessQuarantineOffers_2WithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessQuarantineOffers_2WithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_2'][0]) + { + $request = $this->getBusinessQuarantineOffers_2Request($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessQuarantineOffers_2Async + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffers_2Async($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_2'][0]) + { + return $this->getBusinessQuarantineOffers_2AsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessQuarantineOffers_2AsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffers_2AsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getBusinessQuarantineOffers_2Request($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessQuarantineOffers_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessQuarantineOffers_2Request($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessQuarantineOffers_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getBusinessQuarantineOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getBusinessQuarantineOffers_2' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessSettings_1 + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessSettings_1($business_id, string $contentType = self::contentTypes['getBusinessSettings_1'][0]) + { + list($response) = $this->getBusinessSettings_1WithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getBusinessSettings_1WithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessSettings_1WithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings_1'][0]) + { + $request = $this->getBusinessSettings_1Request($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessSettings_1Async + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettings_1Async($business_id, string $contentType = self::contentTypes['getBusinessSettings_1'][0]) + { + return $this->getBusinessSettings_1AsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessSettings_1AsyncWithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettings_1AsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + $request = $this->getBusinessSettings_1Request($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessSettings_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessSettings_1Request($business_id, string $contentType = self::contentTypes['getBusinessSettings_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessSettings_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getBusinessSettings_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignLogins_2 + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignLogins_2($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_2'][0]) + { + list($response) = $this->getCampaignLogins_2WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignLogins_2WithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignLogins_2WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_2'][0]) + { + $request = $this->getCampaignLogins_2Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignLoginsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignLoginsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignLogins_2Async + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLogins_2Async($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_2'][0]) + { + return $this->getCampaignLogins_2AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignLogins_2AsyncWithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLogins_2AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + $request = $this->getCampaignLogins_2Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignLogins_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignLogins_2Request($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignLogins_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getCampaignLogins_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/logins'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignOffers_2 + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignOffers_2($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_2'][0]) + { + list($response) = $this->getCampaignOffers_2WithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignOffers_2WithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignOffers_2WithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_2'][0]) + { + $request = $this->getCampaignOffers_2Request($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignOffers_2Async + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffers_2Async($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_2'][0]) + { + return $this->getCampaignOffers_2AsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignOffers_2AsyncWithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffers_2AsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + $request = $this->getCampaignOffers_2Request($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignOffers_2Request($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getCampaignOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_campaign_offers_request' is set + if ($get_campaign_offers_request === null || (is_array($get_campaign_offers_request) && count($get_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_campaign_offers_request when calling getCampaignOffers_2' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_campaign_offers_request)); + } else { + $httpBody = $get_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignQuarantineOffers_2 + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignQuarantineOffers_2($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_2'][0]) + { + list($response) = $this->getCampaignQuarantineOffers_2WithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignQuarantineOffers_2WithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignQuarantineOffers_2WithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_2'][0]) + { + $request = $this->getCampaignQuarantineOffers_2Request($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignQuarantineOffers_2Async + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffers_2Async($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_2'][0]) + { + return $this->getCampaignQuarantineOffers_2AsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignQuarantineOffers_2AsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffers_2AsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getCampaignQuarantineOffers_2Request($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignQuarantineOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignQuarantineOffers_2Request($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignQuarantineOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getCampaignQuarantineOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getCampaignQuarantineOffers_2' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignRegion_2 + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getCampaignRegion_2($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_2'][0]) + { + list($response) = $this->getCampaignRegion_2WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignRegion_2WithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getCampaignRegion_2WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_2'][0]) + { + $request = $this->getCampaignRegion_2Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignRegionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignRegionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignRegion_2Async + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegion_2Async($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_2'][0]) + { + return $this->getCampaignRegion_2AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignRegion_2AsyncWithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegion_2AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + $request = $this->getCampaignRegion_2Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignRegion_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getCampaignRegion_2Request($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignRegion_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getCampaignRegion_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/region'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignSettings_1 + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignSettings_1($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_1'][0]) + { + list($response) = $this->getCampaignSettings_1WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignSettings_1WithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignSettings_1WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_1'][0]) + { + $request = $this->getCampaignSettings_1Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignSettings_1Async + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettings_1Async($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_1'][0]) + { + return $this->getCampaignSettings_1AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignSettings_1AsyncWithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettings_1AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + $request = $this->getCampaignSettings_1Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignSettings_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignSettings_1Request($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignSettings_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getCampaignSettings_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaign_2 + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaign_2($campaign_id, string $contentType = self::contentTypes['getCampaign_2'][0]) + { + list($response) = $this->getCampaign_2WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaign_2WithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaign_2WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign_2'][0]) + { + $request = $this->getCampaign_2Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaign_2Async + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaign_2Async($campaign_id, string $contentType = self::contentTypes['getCampaign_2'][0]) + { + return $this->getCampaign_2AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaign_2AsyncWithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaign_2AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + $request = $this->getCampaign_2Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaign_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaign_2Request($campaign_id, string $contentType = self::contentTypes['getCampaign_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaign_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getCampaign_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignsByLogin_2 + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignsByLogin_2($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_2'][0]) + { + list($response) = $this->getCampaignsByLogin_2WithHttpInfo($login, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaignsByLogin_2WithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignsByLogin_2WithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_2'][0]) + { + $request = $this->getCampaignsByLogin_2Request($login, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignsByLogin_2Async + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLogin_2Async($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_2'][0]) + { + return $this->getCampaignsByLogin_2AsyncWithHttpInfo($login, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignsByLogin_2AsyncWithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLogin_2AsyncWithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaignsByLogin_2Request($login, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignsByLogin_2' + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignsByLogin_2Request($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_2'][0]) + { + + // verify the required parameter 'login' is set + if ($login === null || (is_array($login) && count($login) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $login when calling getCampaignsByLogin_2' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbsApi.getCampaignsByLogin_2, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/by_login/{login}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($login !== null) { + $resourcePath = str_replace( + '{' . 'login' . '}', + ObjectSerializer::toPathValue($login), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaigns_2 + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaigns_2($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_2'][0]) + { + list($response) = $this->getCampaigns_2WithHttpInfo($page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaigns_2WithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaigns_2WithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_2'][0]) + { + $request = $this->getCampaigns_2Request($page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaigns_2Async + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaigns_2Async($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_2'][0]) + { + return $this->getCampaigns_2AsyncWithHttpInfo($page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaigns_2AsyncWithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaigns_2AsyncWithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaigns_2Request($page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaigns_2' + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaigns_2Request($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_2'][0]) + { + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbsApi.getCampaigns_2, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesMaxSaleQuantum_1 + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesMaxSaleQuantum_1($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_1'][0]) + { + list($response) = $this->getCategoriesMaxSaleQuantum_1WithHttpInfo($get_categories_max_sale_quantum_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesMaxSaleQuantum_1WithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesMaxSaleQuantum_1WithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_1'][0]) + { + $request = $this->getCategoriesMaxSaleQuantum_1Request($get_categories_max_sale_quantum_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesMaxSaleQuantum_1Async + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantum_1Async($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_1'][0]) + { + return $this->getCategoriesMaxSaleQuantum_1AsyncWithHttpInfo($get_categories_max_sale_quantum_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesMaxSaleQuantum_1AsyncWithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantum_1AsyncWithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + $request = $this->getCategoriesMaxSaleQuantum_1Request($get_categories_max_sale_quantum_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesMaxSaleQuantum_1' + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesMaxSaleQuantum_1Request($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_1'][0]) + { + + // verify the required parameter 'get_categories_max_sale_quantum_request' is set + if ($get_categories_max_sale_quantum_request === null || (is_array($get_categories_max_sale_quantum_request) && count($get_categories_max_sale_quantum_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_categories_max_sale_quantum_request when calling getCategoriesMaxSaleQuantum_1' + ); + } + + + $resourcePath = '/categories/max-sale-quantum'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_max_sale_quantum_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_max_sale_quantum_request)); + } else { + $httpBody = $get_categories_max_sale_quantum_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesTree_1 + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesTree_1($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_1'][0]) + { + list($response) = $this->getCategoriesTree_1WithHttpInfo($get_categories_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesTree_1WithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesTree_1WithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_1'][0]) + { + $request = $this->getCategoriesTree_1Request($get_categories_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesTree_1Async + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTree_1Async($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_1'][0]) + { + return $this->getCategoriesTree_1AsyncWithHttpInfo($get_categories_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesTree_1AsyncWithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTree_1AsyncWithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + $request = $this->getCategoriesTree_1Request($get_categories_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesTree_1' + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesTree_1Request($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_1'][0]) + { + + + + $resourcePath = '/categories/tree'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_request)); + } else { + $httpBody = $get_categories_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoryContentParameters_2 + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoryContentParameters_2($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_2'][0]) + { + list($response) = $this->getCategoryContentParameters_2WithHttpInfo($category_id, $contentType); + return $response; + } + + /** + * Operation getCategoryContentParameters_2WithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoryContentParameters_2WithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_2'][0]) + { + $request = $this->getCategoryContentParameters_2Request($category_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoryContentParameters_2Async + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParameters_2Async($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_2'][0]) + { + return $this->getCategoryContentParameters_2AsyncWithHttpInfo($category_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoryContentParameters_2AsyncWithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParameters_2AsyncWithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + $request = $this->getCategoryContentParameters_2Request($category_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoryContentParameters_2' + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoryContentParameters_2Request($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_2'][0]) + { + + // verify the required parameter 'category_id' is set + if ($category_id === null || (is_array($category_id) && count($category_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $category_id when calling getCategoryContentParameters_2' + ); + } + if ($category_id < 1) { + throw new \InvalidArgumentException('invalid value for "$category_id" when calling FbsApi.getCategoryContentParameters_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/category/{categoryId}/parameters'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($category_id !== null) { + $resourcePath = str_replace( + '{' . 'categoryId' . '}', + ObjectSerializer::toPathValue($category_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChatHistory_1 + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChatHistory_1($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_1'][0]) + { + list($response) = $this->getChatHistory_1WithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChatHistory_1WithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChatHistory_1WithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_1'][0]) + { + $request = $this->getChatHistory_1Request($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatHistoryResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatHistoryResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChatHistory_1Async + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistory_1Async($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_1'][0]) + { + return $this->getChatHistory_1AsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChatHistory_1AsyncWithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistory_1AsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + $request = $this->getChatHistory_1Request($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChatHistory_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChatHistory_1Request($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChatHistory_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getChatHistory_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling getChatHistory_1' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling FbsApi.getChatHistory_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chat_history_request' is set + if ($get_chat_history_request === null || (is_array($get_chat_history_request) && count($get_chat_history_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chat_history_request when calling getChatHistory_1' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chat_history_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chat_history_request)); + } else { + $httpBody = $get_chat_history_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChats_1 + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChats_1($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_1'][0]) + { + list($response) = $this->getChats_1WithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChats_1WithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChats_1WithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_1'][0]) + { + $request = $this->getChats_1Request($business_id, $get_chats_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChats_1Async + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChats_1Async($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_1'][0]) + { + return $this->getChats_1AsyncWithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChats_1AsyncWithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChats_1AsyncWithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + $request = $this->getChats_1Request($business_id, $get_chats_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChats_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChats_1Request($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChats_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getChats_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chats_request' is set + if ($get_chats_request === null || (is_array($get_chats_request) && count($get_chats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chats_request when calling getChats_1' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chats_request)); + } else { + $httpBody = $get_chats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getDeliveryServices_0 + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetDeliveryServicesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getDeliveryServices_0(string $contentType = self::contentTypes['getDeliveryServices_0'][0]) + { + list($response) = $this->getDeliveryServices_0WithHttpInfo($contentType); + return $response; + } + + /** + * Operation getDeliveryServices_0WithHttpInfo + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetDeliveryServicesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getDeliveryServices_0WithHttpInfo(string $contentType = self::contentTypes['getDeliveryServices_0'][0]) + { + $request = $this->getDeliveryServices_0Request($contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetDeliveryServicesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetDeliveryServicesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetDeliveryServicesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetDeliveryServicesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetDeliveryServicesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getDeliveryServices_0Async + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDeliveryServices_0Async(string $contentType = self::contentTypes['getDeliveryServices_0'][0]) + { + return $this->getDeliveryServices_0AsyncWithHttpInfo($contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getDeliveryServices_0AsyncWithHttpInfo + * + * Справочник служб доставки + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getDeliveryServices_0AsyncWithHttpInfo(string $contentType = self::contentTypes['getDeliveryServices_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetDeliveryServicesResponse'; + $request = $this->getDeliveryServices_0Request($contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getDeliveryServices_0' + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getDeliveryServices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getDeliveryServices_0Request(string $contentType = self::contentTypes['getDeliveryServices_0'][0]) + { + + + $resourcePath = '/delivery/services'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedIndexLogs_1 + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedIndexLogs_1($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_1'][0]) + { + list($response) = $this->getFeedIndexLogs_1WithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + return $response; + } + + /** + * Operation getFeedIndexLogs_1WithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedIndexLogs_1WithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_1'][0]) + { + $request = $this->getFeedIndexLogs_1Request($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedIndexLogs_1Async + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogs_1Async($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_1'][0]) + { + return $this->getFeedIndexLogs_1AsyncWithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedIndexLogs_1AsyncWithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogs_1AsyncWithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + $request = $this->getFeedIndexLogs_1Request($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedIndexLogs_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedIndexLogs_1Request($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedIndexLogs_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getFeedIndexLogs_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeedIndexLogs_1' + ); + } + + + + + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/index-logs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_from, + 'published_time_from', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_to, + 'published_time_to', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'FeedIndexLogsStatusType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeed_1 + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeed_1($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_1'][0]) + { + list($response) = $this->getFeed_1WithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation getFeed_1WithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeed_1WithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_1'][0]) + { + $request = $this->getFeed_1Request($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeed_1Async + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeed_1Async($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_1'][0]) + { + return $this->getFeed_1AsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeed_1AsyncWithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeed_1AsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + $request = $this->getFeed_1Request($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeed_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeed_1Request($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeed_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getFeed_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeed_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedbackAndCommentUpdates_2 + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedbackAndCommentUpdates_2($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_2'][0]) + { + list($response) = $this->getFeedbackAndCommentUpdates_2WithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType); + return $response; + } + + /** + * Operation getFeedbackAndCommentUpdates_2WithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedbackAndCommentUpdates_2WithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_2'][0]) + { + $request = $this->getFeedbackAndCommentUpdates_2Request($campaign_id, $page_token, $limit, $from_date, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedbackListResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedbackListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedbackAndCommentUpdates_2Async + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdates_2Async($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_2'][0]) + { + return $this->getFeedbackAndCommentUpdates_2AsyncWithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedbackAndCommentUpdates_2AsyncWithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdates_2AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + $request = $this->getFeedbackAndCommentUpdates_2Request($campaign_id, $page_token, $limit, $from_date, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedbackAndCommentUpdates_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedbackAndCommentUpdates_2Request($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedbackAndCommentUpdates_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getFeedbackAndCommentUpdates_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/feedback/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeeds_1 + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeeds_1($campaign_id, string $contentType = self::contentTypes['getFeeds_1'][0]) + { + list($response) = $this->getFeeds_1WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getFeeds_1WithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeeds_1WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds_1'][0]) + { + $request = $this->getFeeds_1Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeeds_1Async + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeeds_1Async($campaign_id, string $contentType = self::contentTypes['getFeeds_1'][0]) + { + return $this->getFeeds_1AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeeds_1AsyncWithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeeds_1AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + $request = $this->getFeeds_1Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeeds_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeeds_1Request($campaign_id, string $contentType = self::contentTypes['getFeeds_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeeds_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getFeeds_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbackComments_1 + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbackComments_1($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_1'][0]) + { + list($response) = $this->getGoodsFeedbackComments_1WithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbackComments_1WithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbackComments_1WithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_1'][0]) + { + $request = $this->getGoodsFeedbackComments_1Request($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbackComments_1Async + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackComments_1Async($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_1'][0]) + { + return $this->getGoodsFeedbackComments_1AsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbackComments_1AsyncWithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackComments_1AsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + $request = $this->getGoodsFeedbackComments_1Request($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbackComments_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbackComments_1Request($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbackComments_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getGoodsFeedbackComments_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_feedback_comments_request' is set + if ($get_goods_feedback_comments_request === null || (is_array($get_goods_feedback_comments_request) && count($get_goods_feedback_comments_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_feedback_comments_request when calling getGoodsFeedbackComments_1' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_comments_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_comments_request)); + } else { + $httpBody = $get_goods_feedback_comments_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbacks_1 + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbacks_1($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_1'][0]) + { + list($response) = $this->getGoodsFeedbacks_1WithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbacks_1WithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbacks_1WithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_1'][0]) + { + $request = $this->getGoodsFeedbacks_1Request($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbacks_1Async + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacks_1Async($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_1'][0]) + { + return $this->getGoodsFeedbacks_1AsyncWithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbacks_1AsyncWithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacks_1AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + $request = $this->getGoodsFeedbacks_1Request($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbacks_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbacks_1Request($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbacks_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getGoodsFeedbacks_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_request)); + } else { + $httpBody = $get_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsStats_1 + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsStats_1($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_1'][0]) + { + list($response) = $this->getGoodsStats_1WithHttpInfo($campaign_id, $get_goods_stats_request, $contentType); + return $response; + } + + /** + * Operation getGoodsStats_1WithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsStats_1WithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_1'][0]) + { + $request = $this->getGoodsStats_1Request($campaign_id, $get_goods_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsStats_1Async + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStats_1Async($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_1'][0]) + { + return $this->getGoodsStats_1AsyncWithHttpInfo($campaign_id, $get_goods_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsStats_1AsyncWithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStats_1AsyncWithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + $request = $this->getGoodsStats_1Request($campaign_id, $get_goods_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsStats_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsStats_1Request($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getGoodsStats_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getGoodsStats_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_stats_request' is set + if ($get_goods_stats_request === null || (is_array($get_goods_stats_request) && count($get_goods_stats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_stats_request when calling getGoodsStats_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/stats/skus'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_stats_request)); + } else { + $httpBody = $get_goods_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getHiddenOffers_1 + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getHiddenOffers_1($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_1'][0]) + { + list($response) = $this->getHiddenOffers_1WithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getHiddenOffers_1WithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getHiddenOffers_1WithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_1'][0]) + { + $request = $this->getHiddenOffers_1Request($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetHiddenOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetHiddenOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getHiddenOffers_1Async + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffers_1Async($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_1'][0]) + { + return $this->getHiddenOffers_1AsyncWithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getHiddenOffers_1AsyncWithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffers_1AsyncWithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + $request = $this->getHiddenOffers_1Request($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getHiddenOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getHiddenOffers_1Request($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getHiddenOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getHiddenOffers_1, must be bigger than or equal to 1.'); + } + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbsApi.getHiddenOffers_1, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offset, + 'offset', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferCardsContentStatus_2 + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferCardsContentStatus_2($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_2'][0]) + { + list($response) = $this->getOfferCardsContentStatus_2WithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + return $response; + } + + /** + * Operation getOfferCardsContentStatus_2WithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferCardsContentStatus_2WithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_2'][0]) + { + $request = $this->getOfferCardsContentStatus_2Request($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferCardsContentStatus_2Async + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatus_2Async($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_2'][0]) + { + return $this->getOfferCardsContentStatus_2AsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferCardsContentStatus_2AsyncWithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatus_2AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + $request = $this->getOfferCardsContentStatus_2Request($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferCardsContentStatus_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferCardsContentStatus_2Request($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferCardsContentStatus_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getOfferCardsContentStatus_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-cards'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_cards_content_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_cards_content_status_request)); + } else { + $httpBody = $get_offer_cards_content_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappingEntries_1 + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOfferMappingEntries_1($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_1'][0]) + { + list($response) = $this->getOfferMappingEntries_1WithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferMappingEntries_1WithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOfferMappingEntries_1WithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_1'][0]) + { + $request = $this->getOfferMappingEntries_1Request($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappingEntries_1Async + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntries_1Async($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_1'][0]) + { + return $this->getOfferMappingEntries_1AsyncWithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappingEntries_1AsyncWithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntries_1AsyncWithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + $request = $this->getOfferMappingEntries_1Request($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappingEntries_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOfferMappingEntries_1Request($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOfferMappingEntries_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getOfferMappingEntries_1, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_sku, + 'shop_sku', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $mapping_kind, + 'mapping_kind', // param base name + 'OfferMappingKindType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $availability, + 'availability', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $category_id, + 'category_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $vendor, + 'vendor', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappings_2 + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferMappings_2($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_2'][0]) + { + list($response) = $this->getOfferMappings_2WithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getOfferMappings_2WithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferMappings_2WithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_2'][0]) + { + $request = $this->getOfferMappings_2Request($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappings_2Async + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappings_2Async($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_2'][0]) + { + return $this->getOfferMappings_2AsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappings_2AsyncWithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappings_2AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + $request = $this->getOfferMappings_2Request($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappings_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferMappings_2Request($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferMappings_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getOfferMappings_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-mappings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_mappings_request)); + } else { + $httpBody = $get_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferRecommendations_2 + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferRecommendations_2($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_2'][0]) + { + list($response) = $this->getOfferRecommendations_2WithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferRecommendations_2WithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferRecommendations_2WithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_2'][0]) + { + $request = $this->getOfferRecommendations_2Request($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferRecommendations_2Async + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendations_2Async($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_2'][0]) + { + return $this->getOfferRecommendations_2AsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferRecommendations_2AsyncWithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendations_2AsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + $request = $this->getOfferRecommendations_2Request($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferRecommendations_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferRecommendations_2Request($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferRecommendations_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getOfferRecommendations_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_offer_recommendations_request' is set + if ($get_offer_recommendations_request === null || (is_array($get_offer_recommendations_request) && count($get_offer_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_offer_recommendations_request when calling getOfferRecommendations_2' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/offers/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_recommendations_request)); + } else { + $httpBody = $get_offer_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOffers_1 + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOffers_1($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_1'][0]) + { + list($response) = $this->getOffers_1WithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getOffers_1WithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOffers_1WithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_1'][0]) + { + $request = $this->getOffers_1Request($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOffers_1Async + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffers_1Async($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_1'][0]) + { + return $this->getOffers_1AsyncWithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOffers_1AsyncWithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffers_1AsyncWithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + $request = $this->getOffers_1Request($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOffers_1Request($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getOffers_1, must be bigger than or equal to 1.'); + } + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbsApi.getOffers_1, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_category_id, + 'shopCategoryId', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $matched, + 'matched', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessBuyerInfo_0 + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessBuyerInfo_0($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_0'][0]) + { + list($response) = $this->getOrderBusinessBuyerInfo_0WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessBuyerInfo_0WithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessBuyerInfo_0WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_0'][0]) + { + $request = $this->getOrderBusinessBuyerInfo_0Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessBuyerInfo_0Async + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfo_0Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_0'][0]) + { + return $this->getOrderBusinessBuyerInfo_0AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessBuyerInfo_0AsyncWithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfo_0AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + $request = $this->getOrderBusinessBuyerInfo_0Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessBuyerInfo_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessBuyerInfo_0Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessBuyerInfo_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getOrderBusinessBuyerInfo_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessBuyerInfo_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/business-buyer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo_0 + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessDocumentsInfo_0($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_0'][0]) + { + list($response) = $this->getOrderBusinessDocumentsInfo_0WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessDocumentsInfo_0WithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessDocumentsInfo_0WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_0'][0]) + { + $request = $this->getOrderBusinessDocumentsInfo_0Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessDocumentsInfo_0Async + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfo_0Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_0'][0]) + { + return $this->getOrderBusinessDocumentsInfo_0AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo_0AsyncWithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfo_0AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + $request = $this->getOrderBusinessDocumentsInfo_0Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessDocumentsInfo_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessDocumentsInfo_0Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessDocumentsInfo_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getOrderBusinessDocumentsInfo_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessDocumentsInfo_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/documents'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderLabelsData_0 + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderLabelsDataResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderLabelsData_0($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_0'][0]) + { + list($response) = $this->getOrderLabelsData_0WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderLabelsData_0WithHttpInfo + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderLabelsDataResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderLabelsData_0WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_0'][0]) + { + $request = $this->getOrderLabelsData_0Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderLabelsDataResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderLabelsDataResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderLabelsDataResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderLabelsDataResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderLabelsDataResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderLabelsData_0Async + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderLabelsData_0Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_0'][0]) + { + return $this->getOrderLabelsData_0AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderLabelsData_0AsyncWithHttpInfo + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderLabelsData_0AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderLabelsDataResponse'; + $request = $this->getOrderLabelsData_0Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderLabelsData_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderLabelsData_0Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderLabelsData_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getOrderLabelsData_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderLabelsData_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/labels/data'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrder_1 + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrder_1($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_1'][0]) + { + list($response) = $this->getOrder_1WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrder_1WithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrder_1WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_1'][0]) + { + $request = $this->getOrder_1Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrder_1Async + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrder_1Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_1'][0]) + { + return $this->getOrder_1AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrder_1AsyncWithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrder_1AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + $request = $this->getOrder_1Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrder_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrder_1Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrder_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getOrder_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrder_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrdersStats_1 + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrdersStats_1($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_1'][0]) + { + list($response) = $this->getOrdersStats_1WithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + return $response; + } + + /** + * Operation getOrdersStats_1WithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrdersStats_1WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_1'][0]) + { + $request = $this->getOrdersStats_1Request($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrdersStats_1Async + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStats_1Async($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_1'][0]) + { + return $this->getOrdersStats_1AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrdersStats_1AsyncWithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStats_1AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + $request = $this->getOrdersStats_1Request($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrdersStats_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrdersStats_1Request($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrdersStats_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getOrdersStats_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/stats/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_orders_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_orders_stats_request)); + } else { + $httpBody = $get_orders_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrders_0 + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrders_0($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_0'][0]) + { + list($response) = $this->getOrders_0WithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOrders_0WithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrders_0WithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_0'][0]) + { + $request = $this->getOrders_0Request($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrders_0Async + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrders_0Async($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_0'][0]) + { + return $this->getOrders_0AsyncWithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrders_0AsyncWithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrders_0AsyncWithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + $request = $this->getOrders_0Request($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrders_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrders_0Request($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrders_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getOrders_0, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbsApi.getOrders_0, must be smaller than or equal to 10000.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $substatus, + 'substatus', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_from, + 'supplierShipmentDateFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_to, + 'supplierShipmentDateTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_from, + 'updatedAtFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_to, + 'updatedAtTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $dispatch_type, + 'dispatchType', // param base name + 'OrderDeliveryDispatchType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $fake, + 'fake', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $has_cis, + 'hasCis', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_waiting_for_cancellation_approve, + 'onlyWaitingForCancellationApprove', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_estimated_delivery, + 'onlyEstimatedDelivery', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_type, + 'buyerType', // param base name + 'OrderBuyerType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPricesByOfferIds_1 + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPricesByOfferIds_1($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_1'][0]) + { + list($response) = $this->getPricesByOfferIds_1WithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + return $response; + } + + /** + * Operation getPricesByOfferIds_1WithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPricesByOfferIds_1WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_1'][0]) + { + $request = $this->getPricesByOfferIds_1Request($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPricesByOfferIds_1Async + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIds_1Async($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_1'][0]) + { + return $this->getPricesByOfferIds_1AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPricesByOfferIds_1AsyncWithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIds_1AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + $request = $this->getPricesByOfferIds_1Request($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPricesByOfferIds_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPricesByOfferIds_1Request($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPricesByOfferIds_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getPricesByOfferIds_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_prices_by_offer_ids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_prices_by_offer_ids_request)); + } else { + $httpBody = $get_prices_by_offer_ids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPrices_1 + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getPrices_1($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_1'][0]) + { + list($response) = $this->getPrices_1WithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType); + return $response; + } + + /** + * Operation getPrices_1WithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getPrices_1WithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_1'][0]) + { + $request = $this->getPrices_1Request($campaign_id, $page_token, $limit, $archived, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPrices_1Async + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPrices_1Async($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_1'][0]) + { + return $this->getPrices_1AsyncWithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPrices_1AsyncWithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPrices_1AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + $request = $this->getPrices_1Request($campaign_id, $page_token, $limit, $archived, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPrices_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getPrices_1Request($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPrices_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getPrices_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromoOffers_1 + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromoOffers_1($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_1'][0]) + { + list($response) = $this->getPromoOffers_1WithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getPromoOffers_1WithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromoOffers_1WithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_1'][0]) + { + $request = $this->getPromoOffers_1Request($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromoOffers_1Async + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffers_1Async($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_1'][0]) + { + return $this->getPromoOffers_1AsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromoOffers_1AsyncWithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffers_1AsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + $request = $this->getPromoOffers_1Request($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromoOffers_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromoOffers_1Request($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromoOffers_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getPromoOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_promo_offers_request' is set + if ($get_promo_offers_request === null || (is_array($get_promo_offers_request) && count($get_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_promo_offers_request when calling getPromoOffers_1' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/promos/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promo_offers_request)); + } else { + $httpBody = $get_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromos_1 + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromos_1($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_1'][0]) + { + list($response) = $this->getPromos_1WithHttpInfo($business_id, $get_promos_request, $contentType); + return $response; + } + + /** + * Operation getPromos_1WithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromos_1WithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_1'][0]) + { + $request = $this->getPromos_1Request($business_id, $get_promos_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromosResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromosResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromosResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromosResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromos_1Async + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromos_1Async($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_1'][0]) + { + return $this->getPromos_1AsyncWithHttpInfo($business_id, $get_promos_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromos_1AsyncWithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromos_1AsyncWithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + $request = $this->getPromos_1Request($business_id, $get_promos_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromos_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromos_1Request($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromos_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getPromos_1, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/promos'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promos_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promos_request)); + } else { + $httpBody = $get_promos_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getQualityRatingDetails_0 + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingDetailsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatingDetails_0($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_0'][0]) + { + list($response) = $this->getQualityRatingDetails_0WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getQualityRatingDetails_0WithHttpInfo + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingDetailsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatingDetails_0WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_0'][0]) + { + $request = $this->getQualityRatingDetails_0Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingDetailsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingDetailsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatingDetails_0Async + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingDetails_0Async($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_0'][0]) + { + return $this->getQualityRatingDetails_0AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatingDetails_0AsyncWithHttpInfo + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingDetails_0AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse'; + $request = $this->getQualityRatingDetails_0Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatingDetails_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatingDetails_0Request($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getQualityRatingDetails_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getQualityRatingDetails_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/ratings/quality/details'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getQualityRatings_1 + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatings_1($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_1'][0]) + { + list($response) = $this->getQualityRatings_1WithHttpInfo($business_id, $get_quality_rating_request, $contentType); + return $response; + } + + /** + * Operation getQualityRatings_1WithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatings_1WithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_1'][0]) + { + $request = $this->getQualityRatings_1Request($business_id, $get_quality_rating_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatings_1Async + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatings_1Async($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_1'][0]) + { + return $this->getQualityRatings_1AsyncWithHttpInfo($business_id, $get_quality_rating_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatings_1AsyncWithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatings_1AsyncWithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + $request = $this->getQualityRatings_1Request($business_id, $get_quality_rating_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatings_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatings_1Request($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getQualityRatings_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getQualityRatings_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quality_rating_request' is set + if ($get_quality_rating_request === null || (is_array($get_quality_rating_request) && count($get_quality_rating_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quality_rating_request when calling getQualityRatings_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/ratings/quality'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quality_rating_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quality_rating_request)); + } else { + $httpBody = $get_quality_rating_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReportInfo_2 + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReportInfo_2($report_id, string $contentType = self::contentTypes['getReportInfo_2'][0]) + { + list($response) = $this->getReportInfo_2WithHttpInfo($report_id, $contentType); + return $response; + } + + /** + * Operation getReportInfo_2WithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReportInfo_2WithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo_2'][0]) + { + $request = $this->getReportInfo_2Request($report_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReportInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReportInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReportInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReportInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReportInfo_2Async + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfo_2Async($report_id, string $contentType = self::contentTypes['getReportInfo_2'][0]) + { + return $this->getReportInfo_2AsyncWithHttpInfo($report_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReportInfo_2AsyncWithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfo_2AsyncWithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + $request = $this->getReportInfo_2Request($report_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReportInfo_2' + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReportInfo_2Request($report_id, string $contentType = self::contentTypes['getReportInfo_2'][0]) + { + + // verify the required parameter 'report_id' is set + if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $report_id when calling getReportInfo_2' + ); + } + + + $resourcePath = '/reports/info/{reportId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($report_id !== null) { + $resourcePath = str_replace( + '{' . 'reportId' . '}', + ObjectSerializer::toPathValue($report_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnApplication_0 + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnApplication_0($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_0'][0]) + { + list($response) = $this->getReturnApplication_0WithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturnApplication_0WithHttpInfo + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnApplication_0WithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_0'][0]) + { + $request = $this->getReturnApplication_0Request($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnApplication_0Async + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnApplication_0Async($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_0'][0]) + { + return $this->getReturnApplication_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnApplication_0AsyncWithHttpInfo + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnApplication_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnApplication_0Request($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnApplication_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnApplication_0Request($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnApplication_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getReturnApplication_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnApplication_0' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnApplication_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/application'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnPhoto_0 + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnPhoto_0($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_0'][0]) + { + list($response) = $this->getReturnPhoto_0WithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + return $response; + } + + /** + * Operation getReturnPhoto_0WithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnPhoto_0WithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_0'][0]) + { + $request = $this->getReturnPhoto_0Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnPhoto_0Async + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhoto_0Async($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_0'][0]) + { + return $this->getReturnPhoto_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnPhoto_0AsyncWithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhoto_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_0'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnPhoto_0Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnPhoto_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnPhoto_0Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnPhoto_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getReturnPhoto_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnPhoto_0' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnPhoto_0' + ); + } + + // verify the required parameter 'item_id' is set + if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $item_id when calling getReturnPhoto_0' + ); + } + + // verify the required parameter 'image_hash' is set + if ($image_hash === null || (is_array($image_hash) && count($image_hash) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $image_hash when calling getReturnPhoto_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision/{itemId}/image/{imageHash}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + // path params + if ($item_id !== null) { + $resourcePath = str_replace( + '{' . 'itemId' . '}', + ObjectSerializer::toPathValue($item_id), + $resourcePath + ); + } + // path params + if ($image_hash !== null) { + $resourcePath = str_replace( + '{' . 'imageHash' . '}', + ObjectSerializer::toPathValue($image_hash), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturn_0 + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturn_0($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_0'][0]) + { + list($response) = $this->getReturn_0WithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturn_0WithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturn_0WithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_0'][0]) + { + $request = $this->getReturn_0Request($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturn_0Async + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturn_0Async($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_0'][0]) + { + return $this->getReturn_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturn_0AsyncWithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturn_0AsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + $request = $this->getReturn_0Request($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturn_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturn_0Request($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturn_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getReturn_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturn_0' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturn_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturns_0 + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturns_0($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_0'][0]) + { + list($response) = $this->getReturns_0WithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + return $response; + } + + /** + * Operation getReturns_0WithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturns_0WithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_0'][0]) + { + $request = $this->getReturns_0Request($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturns_0Async + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturns_0Async($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_0'][0]) + { + return $this->getReturns_0AsyncWithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturns_0AsyncWithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturns_0AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + $request = $this->getReturns_0Request($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturns_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturns_0Request($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturns_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getReturns_0, must be bigger than or equal to 1.'); + } + + + + if ($order_ids !== null && count($order_ids) > 50) { + throw new \InvalidArgumentException('invalid value for "$order_ids" when calling FbsApi.getReturns_0, number of items must be less than or equal to 50.'); + } + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/returns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $statuses, + 'statuses', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $type, + 'type', // param base name + 'ReturnType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date2, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date2, + 'to_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getShipmentOrdersInfo_0 + * + * Получение информации о возможности печати ярлыков (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetShipmentOrdersInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getShipmentOrdersInfo_0($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo_0'][0]) + { + list($response) = $this->getShipmentOrdersInfo_0WithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation getShipmentOrdersInfo_0WithHttpInfo + * + * Получение информации о возможности печати ярлыков (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetShipmentOrdersInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getShipmentOrdersInfo_0WithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo_0'][0]) + { + $request = $this->getShipmentOrdersInfo_0Request($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getShipmentOrdersInfo_0Async + * + * Получение информации о возможности печати ярлыков (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getShipmentOrdersInfo_0Async($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo_0'][0]) + { + return $this->getShipmentOrdersInfo_0AsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getShipmentOrdersInfo_0AsyncWithHttpInfo + * + * Получение информации о возможности печати ярлыков (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getShipmentOrdersInfo_0AsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse'; + $request = $this->getShipmentOrdersInfo_0Request($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getShipmentOrdersInfo_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getShipmentOrdersInfo_0Request($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getShipmentOrdersInfo_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getShipmentOrdersInfo_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling getShipmentOrdersInfo_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.getShipmentOrdersInfo_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/orders/info'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getShipment_0 + * + * Получение информации об одной отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetShipmentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getShipment_0($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment_0'][0]) + { + list($response) = $this->getShipment_0WithHttpInfo($campaign_id, $shipment_id, $cancelled_orders, $contentType); + return $response; + } + + /** + * Operation getShipment_0WithHttpInfo + * + * Получение информации об одной отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetShipmentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getShipment_0WithHttpInfo($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment_0'][0]) + { + $request = $this->getShipment_0Request($campaign_id, $shipment_id, $cancelled_orders, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetShipmentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetShipmentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetShipmentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetShipmentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetShipmentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getShipment_0Async + * + * Получение информации об одной отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getShipment_0Async($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment_0'][0]) + { + return $this->getShipment_0AsyncWithHttpInfo($campaign_id, $shipment_id, $cancelled_orders, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getShipment_0AsyncWithHttpInfo + * + * Получение информации об одной отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getShipment_0AsyncWithHttpInfo($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetShipmentResponse'; + $request = $this->getShipment_0Request($campaign_id, $shipment_id, $cancelled_orders, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getShipment_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getShipment_0Request($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getShipment_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getShipment_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling getShipment_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.getShipment_0, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cancelled_orders, + 'cancelledOrders', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getStocks_1 + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getStocks_1($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_1'][0]) + { + list($response) = $this->getStocks_1WithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + return $response; + } + + /** + * Operation getStocks_1WithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getStocks_1WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_1'][0]) + { + $request = $this->getStocks_1Request($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehouseStocksResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehouseStocksResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getStocks_1Async + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocks_1Async($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_1'][0]) + { + return $this->getStocks_1AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getStocks_1AsyncWithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocks_1AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + $request = $this->getStocks_1Request($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getStocks_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getStocks_1Request($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getStocks_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getStocks_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_warehouse_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_warehouse_stocks_request)); + } else { + $httpBody = $get_warehouse_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappingEntries_1 + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedOfferMappingEntries_1($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_1'][0]) + { + list($response) = $this->getSuggestedOfferMappingEntries_1WithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappingEntries_1WithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedOfferMappingEntries_1WithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_1'][0]) + { + $request = $this->getSuggestedOfferMappingEntries_1Request($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappingEntries_1Async + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntries_1Async($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_1'][0]) + { + return $this->getSuggestedOfferMappingEntries_1AsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappingEntries_1AsyncWithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntries_1AsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + $request = $this->getSuggestedOfferMappingEntries_1Request($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappingEntries_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedOfferMappingEntries_1Request($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedOfferMappingEntries_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getSuggestedOfferMappingEntries_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_suggested_offer_mapping_entries_request' is set + if ($get_suggested_offer_mapping_entries_request === null || (is_array($get_suggested_offer_mapping_entries_request) && count($get_suggested_offer_mapping_entries_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_suggested_offer_mapping_entries_request when calling getSuggestedOfferMappingEntries_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mapping_entries_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mapping_entries_request)); + } else { + $httpBody = $get_suggested_offer_mapping_entries_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappings_2 + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getSuggestedOfferMappings_2($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_2'][0]) + { + list($response) = $this->getSuggestedOfferMappings_2WithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappings_2WithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getSuggestedOfferMappings_2WithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_2'][0]) + { + $request = $this->getSuggestedOfferMappings_2Request($business_id, $get_suggested_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappings_2Async + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappings_2Async($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_2'][0]) + { + return $this->getSuggestedOfferMappings_2AsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappings_2AsyncWithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappings_2AsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + $request = $this->getSuggestedOfferMappings_2Request($business_id, $get_suggested_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappings_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getSuggestedOfferMappings_2Request($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getSuggestedOfferMappings_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getSuggestedOfferMappings_2, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/offer-mappings/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mappings_request)); + } else { + $httpBody = $get_suggested_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedPrices_1 + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedPrices_1($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_1'][0]) + { + list($response) = $this->getSuggestedPrices_1WithHttpInfo($campaign_id, $suggest_prices_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedPrices_1WithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedPrices_1WithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_1'][0]) + { + $request = $this->getSuggestedPrices_1Request($campaign_id, $suggest_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SuggestPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SuggestPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SuggestPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SuggestPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedPrices_1Async + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPrices_1Async($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_1'][0]) + { + return $this->getSuggestedPrices_1AsyncWithHttpInfo($campaign_id, $suggest_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedPrices_1AsyncWithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPrices_1AsyncWithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + $request = $this->getSuggestedPrices_1Request($campaign_id, $suggest_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedPrices_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedPrices_1Request($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedPrices_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.getSuggestedPrices_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'suggest_prices_request' is set + if ($suggest_prices_request === null || (is_array($suggest_prices_request) && count($suggest_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $suggest_prices_request when calling getSuggestedPrices_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($suggest_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($suggest_prices_request)); + } else { + $httpBody = $suggest_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getWarehouses_0 + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getWarehouses_0($business_id, string $contentType = self::contentTypes['getWarehouses_0'][0]) + { + list($response) = $this->getWarehouses_0WithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getWarehouses_0WithHttpInfo + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getWarehouses_0WithHttpInfo($business_id, string $contentType = self::contentTypes['getWarehouses_0'][0]) + { + $request = $this->getWarehouses_0Request($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehousesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehousesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehousesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehousesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehousesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getWarehouses_0Async + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getWarehouses_0Async($business_id, string $contentType = self::contentTypes['getWarehouses_0'][0]) + { + return $this->getWarehouses_0AsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getWarehouses_0AsyncWithHttpInfo + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getWarehouses_0AsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getWarehouses_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehousesResponse'; + $request = $this->getWarehouses_0Request($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getWarehouses_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getWarehouses_0Request($business_id, string $contentType = self::contentTypes['getWarehouses_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getWarehouses_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.getWarehouses_0, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/warehouses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation provideOrderItemIdentifiers_0 + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function provideOrderItemIdentifiers_0($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_0'][0]) + { + list($response) = $this->provideOrderItemIdentifiers_0WithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + return $response; + } + + /** + * Operation provideOrderItemIdentifiers_0WithHttpInfo + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function provideOrderItemIdentifiers_0WithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_0'][0]) + { + $request = $this->provideOrderItemIdentifiers_0Request($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation provideOrderItemIdentifiers_0Async + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderItemIdentifiers_0Async($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_0'][0]) + { + return $this->provideOrderItemIdentifiers_0AsyncWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation provideOrderItemIdentifiers_0AsyncWithHttpInfo + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderItemIdentifiers_0AsyncWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse'; + $request = $this->provideOrderItemIdentifiers_0Request($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'provideOrderItemIdentifiers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function provideOrderItemIdentifiers_0Request($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling provideOrderItemIdentifiers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.provideOrderItemIdentifiers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling provideOrderItemIdentifiers_0' + ); + } + + // verify the required parameter 'provide_order_item_identifiers_request' is set + if ($provide_order_item_identifiers_request === null || (is_array($provide_order_item_identifiers_request) && count($provide_order_item_identifiers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $provide_order_item_identifiers_request when calling provideOrderItemIdentifiers_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/identifiers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($provide_order_item_identifiers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($provide_order_item_identifiers_request)); + } else { + $httpBody = $provide_order_item_identifiers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForBusiness_1 + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForBusiness_1($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_1'][0]) + { + list($response) = $this->putBidsForBusiness_1WithHttpInfo($business_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForBusiness_1WithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForBusiness_1WithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_1'][0]) + { + $request = $this->putBidsForBusiness_1Request($business_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForBusiness_1Async + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusiness_1Async($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_1'][0]) + { + return $this->putBidsForBusiness_1AsyncWithHttpInfo($business_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForBusiness_1AsyncWithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusiness_1AsyncWithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForBusiness_1Request($business_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForBusiness_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForBusiness_1Request($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling putBidsForBusiness_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.putBidsForBusiness_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForBusiness_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForCampaign_1 + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForCampaign_1($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_1'][0]) + { + list($response) = $this->putBidsForCampaign_1WithHttpInfo($campaign_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForCampaign_1WithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForCampaign_1WithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_1'][0]) + { + $request = $this->putBidsForCampaign_1Request($campaign_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForCampaign_1Async + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaign_1Async($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_1'][0]) + { + return $this->putBidsForCampaign_1AsyncWithHttpInfo($campaign_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForCampaign_1AsyncWithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaign_1AsyncWithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForCampaign_1Request($campaign_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForCampaign_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForCampaign_1Request($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling putBidsForCampaign_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.putBidsForCampaign_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForCampaign_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation refreshFeed_1 + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function refreshFeed_1($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_1'][0]) + { + list($response) = $this->refreshFeed_1WithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation refreshFeed_1WithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function refreshFeed_1WithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_1'][0]) + { + $request = $this->refreshFeed_1Request($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation refreshFeed_1Async + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeed_1Async($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_1'][0]) + { + return $this->refreshFeed_1AsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation refreshFeed_1AsyncWithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeed_1AsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->refreshFeed_1Request($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'refreshFeed_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function refreshFeed_1Request($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling refreshFeed_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.refreshFeed_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling refreshFeed_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/refresh'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionChildren_1 + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionChildren_1($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_1'][0]) + { + list($response) = $this->searchRegionChildren_1WithHttpInfo($region_id, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation searchRegionChildren_1WithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionChildren_1WithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_1'][0]) + { + $request = $this->searchRegionChildren_1Request($region_id, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionChildren_1Async + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildren_1Async($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_1'][0]) + { + return $this->searchRegionChildren_1AsyncWithHttpInfo($region_id, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionChildren_1AsyncWithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildren_1AsyncWithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + $request = $this->searchRegionChildren_1Request($region_id, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionChildren_1' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionChildren_1Request($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_1'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionChildren_1' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbsApi.searchRegionChildren_1, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/regions/{regionId}/children'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsById_1 + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsById_1($region_id, string $contentType = self::contentTypes['searchRegionsById_1'][0]) + { + list($response) = $this->searchRegionsById_1WithHttpInfo($region_id, $contentType); + return $response; + } + + /** + * Operation searchRegionsById_1WithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsById_1WithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById_1'][0]) + { + $request = $this->searchRegionsById_1Request($region_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsById_1Async + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsById_1Async($region_id, string $contentType = self::contentTypes['searchRegionsById_1'][0]) + { + return $this->searchRegionsById_1AsyncWithHttpInfo($region_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsById_1AsyncWithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsById_1AsyncWithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsById_1Request($region_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsById_1' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsById_1Request($region_id, string $contentType = self::contentTypes['searchRegionsById_1'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionsById_1' + ); + } + + + $resourcePath = '/regions/{regionId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsByName_1 + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsByName_1($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_1'][0]) + { + list($response) = $this->searchRegionsByName_1WithHttpInfo($name, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation searchRegionsByName_1WithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsByName_1WithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_1'][0]) + { + $request = $this->searchRegionsByName_1Request($name, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsByName_1Async + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByName_1Async($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_1'][0]) + { + return $this->searchRegionsByName_1AsyncWithHttpInfo($name, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsByName_1AsyncWithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByName_1AsyncWithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsByName_1Request($name, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsByName_1' + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsByName_1Request($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_1'][0]) + { + + // verify the required parameter 'name' is set + if ($name === null || (is_array($name) && count($name) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $name when calling searchRegionsByName_1' + ); + } + + + + + $resourcePath = '/regions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $name, + 'name', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchShipments_0 + * + * Получение информации о нескольких отгрузках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SearchShipmentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchShipments_0($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments_0'][0]) + { + list($response) = $this->searchShipments_0WithHttpInfo($campaign_id, $search_shipments_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation searchShipments_0WithHttpInfo + * + * Получение информации о нескольких отгрузках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SearchShipmentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchShipments_0WithHttpInfo($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments_0'][0]) + { + $request = $this->searchShipments_0Request($campaign_id, $search_shipments_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SearchShipmentsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SearchShipmentsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SearchShipmentsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SearchShipmentsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SearchShipmentsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchShipments_0Async + * + * Получение информации о нескольких отгрузках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchShipments_0Async($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments_0'][0]) + { + return $this->searchShipments_0AsyncWithHttpInfo($campaign_id, $search_shipments_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchShipments_0AsyncWithHttpInfo + * + * Получение информации о нескольких отгрузках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchShipments_0AsyncWithHttpInfo($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\SearchShipmentsResponse'; + $request = $this->searchShipments_0Request($campaign_id, $search_shipments_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchShipments_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchShipments_0Request($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling searchShipments_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.searchShipments_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'search_shipments_request' is set + if ($search_shipments_request === null || (is_array($search_shipments_request) && count($search_shipments_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $search_shipments_request when calling searchShipments_0' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($search_shipments_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($search_shipments_request)); + } else { + $httpBody = $search_shipments_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendFileToChat_1 + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendFileToChat_1($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_1'][0]) + { + list($response) = $this->sendFileToChat_1WithHttpInfo($business_id, $chat_id, $file, $contentType); + return $response; + } + + /** + * Operation sendFileToChat_1WithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendFileToChat_1WithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_1'][0]) + { + $request = $this->sendFileToChat_1Request($business_id, $chat_id, $file, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendFileToChat_1Async + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChat_1Async($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_1'][0]) + { + return $this->sendFileToChat_1AsyncWithHttpInfo($business_id, $chat_id, $file, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendFileToChat_1AsyncWithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChat_1AsyncWithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendFileToChat_1Request($business_id, $chat_id, $file, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendFileToChat_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendFileToChat_1Request($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendFileToChat_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.sendFileToChat_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendFileToChat_1' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling FbsApi.sendFileToChat_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'file' is set + if ($file === null || (is_array($file) && count($file) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $file when calling sendFileToChat_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/file/send'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + // form params + if ($file !== null) { + $multipart = true; + $formParams['file'] = []; + $paramFiles = is_array($file) ? $file : [$file]; + foreach ($paramFiles as $paramFile) { + $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( + ObjectSerializer::toFormValue($paramFile), + 'rb' + ); + } + } + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendMessageToChat_1 + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendMessageToChat_1($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_1'][0]) + { + list($response) = $this->sendMessageToChat_1WithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType); + return $response; + } + + /** + * Operation sendMessageToChat_1WithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendMessageToChat_1WithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_1'][0]) + { + $request = $this->sendMessageToChat_1Request($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendMessageToChat_1Async + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChat_1Async($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_1'][0]) + { + return $this->sendMessageToChat_1AsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendMessageToChat_1AsyncWithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChat_1AsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendMessageToChat_1Request($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendMessageToChat_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendMessageToChat_1Request($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendMessageToChat_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.sendMessageToChat_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendMessageToChat_1' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling FbsApi.sendMessageToChat_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'send_message_to_chat_request' is set + if ($send_message_to_chat_request === null || (is_array($send_message_to_chat_request) && count($send_message_to_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $send_message_to_chat_request when calling sendMessageToChat_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/message'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($send_message_to_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($send_message_to_chat_request)); + } else { + $httpBody = $send_message_to_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setFeedParams_1 + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function setFeedParams_1($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_1'][0]) + { + list($response) = $this->setFeedParams_1WithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType); + return $response; + } + + /** + * Operation setFeedParams_1WithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function setFeedParams_1WithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_1'][0]) + { + $request = $this->setFeedParams_1Request($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setFeedParams_1Async + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParams_1Async($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_1'][0]) + { + return $this->setFeedParams_1AsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setFeedParams_1AsyncWithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParams_1AsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setFeedParams_1Request($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setFeedParams_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function setFeedParams_1Request($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setFeedParams_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.setFeedParams_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling setFeedParams_1' + ); + } + + // verify the required parameter 'set_feed_params_request' is set + if ($set_feed_params_request === null || (is_array($set_feed_params_request) && count($set_feed_params_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_feed_params_request when calling setFeedParams_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/params'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_feed_params_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_feed_params_request)); + } else { + $httpBody = $set_feed_params_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderBoxLayout_0 + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SetOrderBoxLayoutResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderBoxLayout_0($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_0'][0]) + { + list($response) = $this->setOrderBoxLayout_0WithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + return $response; + } + + /** + * Operation setOrderBoxLayout_0WithHttpInfo + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SetOrderBoxLayoutResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderBoxLayout_0WithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_0'][0]) + { + $request = $this->setOrderBoxLayout_0Request($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SetOrderBoxLayoutResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SetOrderBoxLayoutResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderBoxLayout_0Async + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderBoxLayout_0Async($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_0'][0]) + { + return $this->setOrderBoxLayout_0AsyncWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderBoxLayout_0AsyncWithHttpInfo + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderBoxLayout_0AsyncWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse'; + $request = $this->setOrderBoxLayout_0Request($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderBoxLayout_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderBoxLayout_0Request($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderBoxLayout_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.setOrderBoxLayout_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderBoxLayout_0' + ); + } + + // verify the required parameter 'set_order_box_layout_request' is set + if ($set_order_box_layout_request === null || (is_array($set_order_box_layout_request) && count($set_order_box_layout_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_box_layout_request when calling setOrderBoxLayout_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/boxes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_box_layout_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_box_layout_request)); + } else { + $httpBody = $set_order_box_layout_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderShipmentBoxes_0 + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SetOrderShipmentBoxesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderShipmentBoxes_0($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_0'][0]) + { + list($response) = $this->setOrderShipmentBoxes_0WithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + return $response; + } + + /** + * Operation setOrderShipmentBoxes_0WithHttpInfo + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SetOrderShipmentBoxesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderShipmentBoxes_0WithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_0'][0]) + { + $request = $this->setOrderShipmentBoxes_0Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderShipmentBoxes_0Async + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderShipmentBoxes_0Async($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_0'][0]) + { + return $this->setOrderShipmentBoxes_0AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderShipmentBoxes_0AsyncWithHttpInfo + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderShipmentBoxes_0AsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse'; + $request = $this->setOrderShipmentBoxes_0Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderShipmentBoxes_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderShipmentBoxes_0Request($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderShipmentBoxes_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.setOrderShipmentBoxes_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderShipmentBoxes_0' + ); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling setOrderShipmentBoxes_0' + ); + } + + // verify the required parameter 'set_order_shipment_boxes_request' is set + if ($set_order_shipment_boxes_request === null || (is_array($set_order_shipment_boxes_request) && count($set_order_shipment_boxes_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_shipment_boxes_request when calling setOrderShipmentBoxes_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_shipment_boxes_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_shipment_boxes_request)); + } else { + $httpBody = $set_order_shipment_boxes_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setShipmentPalletsCount_0 + * + * Передача количества упаковок в отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setShipmentPalletsCount_0($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount_0'][0]) + { + list($response) = $this->setShipmentPalletsCount_0WithHttpInfo($campaign_id, $shipment_id, $set_shipment_pallets_count_request, $contentType); + return $response; + } + + /** + * Operation setShipmentPalletsCount_0WithHttpInfo + * + * Передача количества упаковок в отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setShipmentPalletsCount_0WithHttpInfo($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount_0'][0]) + { + $request = $this->setShipmentPalletsCount_0Request($campaign_id, $shipment_id, $set_shipment_pallets_count_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setShipmentPalletsCount_0Async + * + * Передача количества упаковок в отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setShipmentPalletsCount_0Async($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount_0'][0]) + { + return $this->setShipmentPalletsCount_0AsyncWithHttpInfo($campaign_id, $shipment_id, $set_shipment_pallets_count_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setShipmentPalletsCount_0AsyncWithHttpInfo + * + * Передача количества упаковок в отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setShipmentPalletsCount_0AsyncWithHttpInfo($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setShipmentPalletsCount_0Request($campaign_id, $shipment_id, $set_shipment_pallets_count_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setShipmentPalletsCount_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setShipmentPalletsCount_0Request($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setShipmentPalletsCount_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.setShipmentPalletsCount_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling setShipmentPalletsCount_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.setShipmentPalletsCount_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'set_shipment_pallets_count_request' is set + if ($set_shipment_pallets_count_request === null || (is_array($set_shipment_pallets_count_request) && count($set_shipment_pallets_count_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_shipment_pallets_count_request when calling setShipmentPalletsCount_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/pallets'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_shipment_pallets_count_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_shipment_pallets_count_request)); + } else { + $httpBody = $set_shipment_pallets_count_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation skipGoodsFeedbacksReaction_1 + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function skipGoodsFeedbacksReaction_1($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_1'][0]) + { + list($response) = $this->skipGoodsFeedbacksReaction_1WithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType); + return $response; + } + + /** + * Operation skipGoodsFeedbacksReaction_1WithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function skipGoodsFeedbacksReaction_1WithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_1'][0]) + { + $request = $this->skipGoodsFeedbacksReaction_1Request($business_id, $skip_goods_feedback_reaction_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation skipGoodsFeedbacksReaction_1Async + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReaction_1Async($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_1'][0]) + { + return $this->skipGoodsFeedbacksReaction_1AsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation skipGoodsFeedbacksReaction_1AsyncWithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReaction_1AsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->skipGoodsFeedbacksReaction_1Request($business_id, $skip_goods_feedback_reaction_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'skipGoodsFeedbacksReaction_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function skipGoodsFeedbacksReaction_1Request($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling skipGoodsFeedbacksReaction_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.skipGoodsFeedbacksReaction_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'skip_goods_feedback_reaction_request' is set + if ($skip_goods_feedback_reaction_request === null || (is_array($skip_goods_feedback_reaction_request) && count($skip_goods_feedback_reaction_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $skip_goods_feedback_reaction_request when calling skipGoodsFeedbacksReaction_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/skip-reaction'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($skip_goods_feedback_reaction_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($skip_goods_feedback_reaction_request)); + } else { + $httpBody = $skip_goods_feedback_reaction_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation transferOrdersFromShipment_0 + * + * Перенос заказов в следующую отгрузку + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function transferOrdersFromShipment_0($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment_0'][0]) + { + list($response) = $this->transferOrdersFromShipment_0WithHttpInfo($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, $contentType); + return $response; + } + + /** + * Operation transferOrdersFromShipment_0WithHttpInfo + * + * Перенос заказов в следующую отгрузку + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function transferOrdersFromShipment_0WithHttpInfo($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment_0'][0]) + { + $request = $this->transferOrdersFromShipment_0Request($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation transferOrdersFromShipment_0Async + * + * Перенос заказов в следующую отгрузку + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function transferOrdersFromShipment_0Async($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment_0'][0]) + { + return $this->transferOrdersFromShipment_0AsyncWithHttpInfo($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation transferOrdersFromShipment_0AsyncWithHttpInfo + * + * Перенос заказов в следующую отгрузку + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function transferOrdersFromShipment_0AsyncWithHttpInfo($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->transferOrdersFromShipment_0Request($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'transferOrdersFromShipment_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function transferOrdersFromShipment_0Request($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling transferOrdersFromShipment_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.transferOrdersFromShipment_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling transferOrdersFromShipment_0' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling FbsApi.transferOrdersFromShipment_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'transfer_orders_from_shipment_request' is set + if ($transfer_orders_from_shipment_request === null || (is_array($transfer_orders_from_shipment_request) && count($transfer_orders_from_shipment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $transfer_orders_from_shipment_request when calling transferOrdersFromShipment_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/orders/transfer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($transfer_orders_from_shipment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($transfer_orders_from_shipment_request)); + } else { + $httpBody = $transfer_orders_from_shipment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateBusinessPrices_1 + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateBusinessPrices_1($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_1'][0]) + { + list($response) = $this->updateBusinessPrices_1WithHttpInfo($business_id, $update_business_prices_request, $contentType); + return $response; + } + + /** + * Operation updateBusinessPrices_1WithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateBusinessPrices_1WithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_1'][0]) + { + $request = $this->updateBusinessPrices_1Request($business_id, $update_business_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateBusinessPrices_1Async + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPrices_1Async($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_1'][0]) + { + return $this->updateBusinessPrices_1AsyncWithHttpInfo($business_id, $update_business_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateBusinessPrices_1AsyncWithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPrices_1AsyncWithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateBusinessPrices_1Request($business_id, $update_business_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateBusinessPrices_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateBusinessPrices_1Request($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateBusinessPrices_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.updateBusinessPrices_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_business_prices_request' is set + if ($update_business_prices_request === null || (is_array($update_business_prices_request) && count($update_business_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_business_prices_request when calling updateBusinessPrices_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_business_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_business_prices_request)); + } else { + $httpBody = $update_business_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateCampaignOffers_2 + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateCampaignOffers_2($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_2'][0]) + { + list($response) = $this->updateCampaignOffers_2WithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation updateCampaignOffers_2WithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateCampaignOffers_2WithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_2'][0]) + { + $request = $this->updateCampaignOffers_2Request($campaign_id, $update_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateCampaignOffers_2Async + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffers_2Async($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_2'][0]) + { + return $this->updateCampaignOffers_2AsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateCampaignOffers_2AsyncWithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffers_2AsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateCampaignOffers_2Request($campaign_id, $update_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateCampaignOffers_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateCampaignOffers_2Request($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateCampaignOffers_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.updateCampaignOffers_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_campaign_offers_request' is set + if ($update_campaign_offers_request === null || (is_array($update_campaign_offers_request) && count($update_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_campaign_offers_request when calling updateCampaignOffers_2' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_campaign_offers_request)); + } else { + $httpBody = $update_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateGoodsFeedbackComment_1 + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateGoodsFeedbackComment_1($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_1'][0]) + { + list($response) = $this->updateGoodsFeedbackComment_1WithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation updateGoodsFeedbackComment_1WithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateGoodsFeedbackComment_1WithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_1'][0]) + { + $request = $this->updateGoodsFeedbackComment_1Request($business_id, $update_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateGoodsFeedbackComment_1Async + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackComment_1Async($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_1'][0]) + { + return $this->updateGoodsFeedbackComment_1AsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateGoodsFeedbackComment_1AsyncWithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackComment_1AsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + $request = $this->updateGoodsFeedbackComment_1Request($business_id, $update_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateGoodsFeedbackComment_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateGoodsFeedbackComment_1Request($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateGoodsFeedbackComment_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.updateGoodsFeedbackComment_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_goods_feedback_comment_request' is set + if ($update_goods_feedback_comment_request === null || (is_array($update_goods_feedback_comment_request) && count($update_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_goods_feedback_comment_request when calling updateGoodsFeedbackComment_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_goods_feedback_comment_request)); + } else { + $httpBody = $update_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferContent_2 + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferContent_2($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_2'][0]) + { + list($response) = $this->updateOfferContent_2WithHttpInfo($business_id, $update_offer_content_request, $contentType); + return $response; + } + + /** + * Operation updateOfferContent_2WithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferContent_2WithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_2'][0]) + { + $request = $this->updateOfferContent_2Request($business_id, $update_offer_content_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferContentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferContentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferContent_2Async + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContent_2Async($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_2'][0]) + { + return $this->updateOfferContent_2AsyncWithHttpInfo($business_id, $update_offer_content_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferContent_2AsyncWithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContent_2AsyncWithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + $request = $this->updateOfferContent_2Request($business_id, $update_offer_content_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferContent_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferContent_2Request($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferContent_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.updateOfferContent_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_content_request' is set + if ($update_offer_content_request === null || (is_array($update_offer_content_request) && count($update_offer_content_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_content_request when calling updateOfferContent_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-cards/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_content_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_content_request)); + } else { + $httpBody = $update_offer_content_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappingEntries_1 + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function updateOfferMappingEntries_1($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_1'][0]) + { + list($response) = $this->updateOfferMappingEntries_1WithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappingEntries_1WithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function updateOfferMappingEntries_1WithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_1'][0]) + { + $request = $this->updateOfferMappingEntries_1Request($campaign_id, $update_offer_mapping_entry_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappingEntries_1Async + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntries_1Async($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_1'][0]) + { + return $this->updateOfferMappingEntries_1AsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappingEntries_1AsyncWithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntries_1AsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOfferMappingEntries_1Request($campaign_id, $update_offer_mapping_entry_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappingEntries_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function updateOfferMappingEntries_1Request($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOfferMappingEntries_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.updateOfferMappingEntries_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mapping_entry_request' is set + if ($update_offer_mapping_entry_request === null || (is_array($update_offer_mapping_entry_request) && count($update_offer_mapping_entry_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mapping_entry_request when calling updateOfferMappingEntries_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mapping_entry_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mapping_entry_request)); + } else { + $httpBody = $update_offer_mapping_entry_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappings_2 + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferMappings_2($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_2'][0]) + { + list($response) = $this->updateOfferMappings_2WithHttpInfo($business_id, $update_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappings_2WithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferMappings_2WithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_2'][0]) + { + $request = $this->updateOfferMappings_2Request($business_id, $update_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappings_2Async + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappings_2Async($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_2'][0]) + { + return $this->updateOfferMappings_2AsyncWithHttpInfo($business_id, $update_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappings_2AsyncWithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappings_2AsyncWithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + $request = $this->updateOfferMappings_2Request($business_id, $update_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappings_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferMappings_2Request($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferMappings_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.updateOfferMappings_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mappings_request' is set + if ($update_offer_mappings_request === null || (is_array($update_offer_mappings_request) && count($update_offer_mappings_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mappings_request when calling updateOfferMappings_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mappings_request)); + } else { + $httpBody = $update_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderItems_0 + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function updateOrderItems_0($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_0'][0]) + { + $this->updateOrderItems_0WithHttpInfo($campaign_id, $order_id, $update_order_item_request, $contentType); + } + + /** + * Operation updateOrderItems_0WithHttpInfo + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderItems_0WithHttpInfo($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_0'][0]) + { + $request = $this->updateOrderItems_0Request($campaign_id, $order_id, $update_order_item_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderItems_0Async + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderItems_0Async($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_0'][0]) + { + return $this->updateOrderItems_0AsyncWithHttpInfo($campaign_id, $order_id, $update_order_item_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderItems_0AsyncWithHttpInfo + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderItems_0AsyncWithHttpInfo($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_0'][0]) + { + $returnType = ''; + $request = $this->updateOrderItems_0Request($campaign_id, $order_id, $update_order_item_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderItems_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderItems_0Request($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderItems_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.updateOrderItems_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderItems_0' + ); + } + + // verify the required parameter 'update_order_item_request' is set + if ($update_order_item_request === null || (is_array($update_order_item_request) && count($update_order_item_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_item_request when calling updateOrderItems_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/items'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_item_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_item_request)); + } else { + $httpBody = $update_order_item_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStatus_0 + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOrderStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStatus_0($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_0'][0]) + { + list($response) = $this->updateOrderStatus_0WithHttpInfo($campaign_id, $order_id, $update_order_status_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStatus_0WithHttpInfo + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOrderStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStatus_0WithHttpInfo($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_0'][0]) + { + $request = $this->updateOrderStatus_0Request($campaign_id, $order_id, $update_order_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOrderStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOrderStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOrderStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOrderStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStatus_0Async + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatus_0Async($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_0'][0]) + { + return $this->updateOrderStatus_0AsyncWithHttpInfo($campaign_id, $order_id, $update_order_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStatus_0AsyncWithHttpInfo + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatus_0AsyncWithHttpInfo($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusResponse'; + $request = $this->updateOrderStatus_0Request($campaign_id, $order_id, $update_order_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStatus_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStatus_0Request($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStatus_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.updateOrderStatus_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderStatus_0' + ); + } + + // verify the required parameter 'update_order_status_request' is set + if ($update_order_status_request === null || (is_array($update_order_status_request) && count($update_order_status_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_status_request when calling updateOrderStatus_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_status_request)); + } else { + $httpBody = $update_order_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStatuses_0 + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOrderStatusesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStatuses_0($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_0'][0]) + { + list($response) = $this->updateOrderStatuses_0WithHttpInfo($campaign_id, $update_order_statuses_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStatuses_0WithHttpInfo + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOrderStatusesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStatuses_0WithHttpInfo($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_0'][0]) + { + $request = $this->updateOrderStatuses_0Request($campaign_id, $update_order_statuses_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOrderStatusesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOrderStatusesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOrderStatusesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOrderStatusesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStatuses_0Async + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatuses_0Async($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_0'][0]) + { + return $this->updateOrderStatuses_0AsyncWithHttpInfo($campaign_id, $update_order_statuses_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStatuses_0AsyncWithHttpInfo + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatuses_0AsyncWithHttpInfo($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusesResponse'; + $request = $this->updateOrderStatuses_0Request($campaign_id, $update_order_statuses_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStatuses_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStatuses_0Request($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStatuses_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.updateOrderStatuses_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_order_statuses_request' is set + if ($update_order_statuses_request === null || (is_array($update_order_statuses_request) && count($update_order_statuses_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_statuses_request when calling updateOrderStatuses_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/status-update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_statuses_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_statuses_request)); + } else { + $httpBody = $update_order_statuses_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePrices_1 + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePrices_1($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_1'][0]) + { + list($response) = $this->updatePrices_1WithHttpInfo($campaign_id, $update_prices_request, $contentType); + return $response; + } + + /** + * Operation updatePrices_1WithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePrices_1WithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_1'][0]) + { + $request = $this->updatePrices_1Request($campaign_id, $update_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePrices_1Async + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePrices_1Async($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_1'][0]) + { + return $this->updatePrices_1AsyncWithHttpInfo($campaign_id, $update_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePrices_1AsyncWithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePrices_1AsyncWithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updatePrices_1Request($campaign_id, $update_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePrices_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePrices_1Request($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updatePrices_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.updatePrices_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_prices_request' is set + if ($update_prices_request === null || (is_array($update_prices_request) && count($update_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_prices_request when calling updatePrices_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_prices_request)); + } else { + $httpBody = $update_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePromoOffers_1 + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePromoOffers_1($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_1'][0]) + { + list($response) = $this->updatePromoOffers_1WithHttpInfo($business_id, $update_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation updatePromoOffers_1WithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePromoOffers_1WithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_1'][0]) + { + $request = $this->updatePromoOffers_1Request($business_id, $update_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdatePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdatePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePromoOffers_1Async + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffers_1Async($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_1'][0]) + { + return $this->updatePromoOffers_1AsyncWithHttpInfo($business_id, $update_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePromoOffers_1AsyncWithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffers_1AsyncWithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + $request = $this->updatePromoOffers_1Request($business_id, $update_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePromoOffers_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePromoOffers_1Request($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updatePromoOffers_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbsApi.updatePromoOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_promo_offers_request' is set + if ($update_promo_offers_request === null || (is_array($update_promo_offers_request) && count($update_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_promo_offers_request when calling updatePromoOffers_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_promo_offers_request)); + } else { + $httpBody = $update_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateStocks_0 + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateStocks_0($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_0'][0]) + { + list($response) = $this->updateStocks_0WithHttpInfo($campaign_id, $update_stocks_request, $contentType); + return $response; + } + + /** + * Operation updateStocks_0WithHttpInfo + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateStocks_0WithHttpInfo($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_0'][0]) + { + $request = $this->updateStocks_0Request($campaign_id, $update_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateStocks_0Async + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateStocks_0Async($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_0'][0]) + { + return $this->updateStocks_0AsyncWithHttpInfo($campaign_id, $update_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateStocks_0AsyncWithHttpInfo + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateStocks_0AsyncWithHttpInfo($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateStocks_0Request($campaign_id, $update_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateStocks_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateStocks_0Request($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateStocks_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbsApi.updateStocks_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_stocks_request' is set + if ($update_stocks_request === null || (is_array($update_stocks_request) && count($update_stocks_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_stocks_request when calling updateStocks_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_stocks_request)); + } else { + $httpBody = $update_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/FbyApi.php b/erp24/lib/yandex_market_api/Api/FbyApi.php new file mode 100644 index 00000000..b4b89a6a --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/FbyApi.php @@ -0,0 +1,52401 @@ + [ + 'application/json', + ], + 'addOffersToArchive_1' => [ + 'application/json', + ], + 'calculateTariffs_1' => [ + 'application/json', + ], + 'confirmBusinessPrices_1' => [ + 'application/json', + ], + 'confirmCampaignPrices_1' => [ + 'application/json', + ], + 'createChat_2' => [ + 'application/json', + ], + 'deleteCampaignOffers_1' => [ + 'application/json', + ], + 'deleteGoodsFeedbackComment_0' => [ + 'application/json', + ], + 'deleteHiddenOffers_0' => [ + 'application/json', + ], + 'deleteOffersFromArchive_1' => [ + 'application/json', + ], + 'deleteOffers_1' => [ + 'application/json', + ], + 'deletePromoOffers_0' => [ + 'application/json', + ], + 'generateBoostConsolidatedReport_0' => [ + 'application/json', + ], + 'generateCompetitorsPositionReport_0' => [ + 'application/json', + ], + 'generateGoodsFeedbackReport_0' => [ + 'application/json', + ], + 'generateGoodsMovementReport_0' => [ + 'application/json', + ], + 'generateGoodsRealizationReport_0' => [ + 'application/json', + ], + 'generateGoodsTurnoverReport_0' => [ + 'application/json', + ], + 'generatePricesReport_0' => [ + 'application/json', + ], + 'generateShelfsStatisticsReport_0' => [ + 'application/json', + ], + 'generateShowsSalesReport_0' => [ + 'application/json', + ], + 'generateStocksOnWarehousesReport_0' => [ + 'application/json', + ], + 'generateUnitedMarketplaceServicesReport_0' => [ + 'application/json', + ], + 'generateUnitedNettingReport_0' => [ + 'application/json', + ], + 'generateUnitedOrdersReport_0' => [ + 'application/json', + ], + 'getAllOffers_3' => [ + 'application/json', + ], + 'getBidsInfoForBusiness_2' => [ + 'application/json', + ], + 'getBidsRecommendations_2' => [ + 'application/json', + ], + 'getBusinessQuarantineOffers_1' => [ + 'application/json', + ], + 'getBusinessSettings_2' => [ + 'application/json', + ], + 'getCampaignLogins_3' => [ + 'application/json', + ], + 'getCampaignOffers_1' => [ + 'application/json', + ], + 'getCampaignQuarantineOffers_1' => [ + 'application/json', + ], + 'getCampaignRegion_1' => [ + 'application/json', + ], + 'getCampaignSettings_3' => [ + 'application/json', + ], + 'getCampaign_3' => [ + 'application/json', + ], + 'getCampaignsByLogin_3' => [ + 'application/json', + ], + 'getCampaigns_3' => [ + 'application/json', + ], + 'getCategoriesMaxSaleQuantum_0' => [ + 'application/json', + ], + 'getCategoriesTree_0' => [ + 'application/json', + ], + 'getCategoryContentParameters_1' => [ + 'application/json', + ], + 'getChatHistory_2' => [ + 'application/json', + ], + 'getChats_2' => [ + 'application/json', + ], + 'getFeedIndexLogs_3' => [ + 'application/json', + ], + 'getFeed_3' => [ + 'application/json', + ], + 'getFeedbackAndCommentUpdates_1' => [ + 'application/json', + ], + 'getFeeds_3' => [ + 'application/json', + ], + 'getFulfillmentWarehouses_0' => [ + 'application/json', + ], + 'getGoodsFeedbackComments_0' => [ + 'application/json', + ], + 'getGoodsFeedbacks_0' => [ + 'application/json', + ], + 'getGoodsStats_0' => [ + 'application/json', + ], + 'getHiddenOffers_0' => [ + 'application/json', + ], + 'getOfferCardsContentStatus_1' => [ + 'application/json', + ], + 'getOfferMappingEntries_0' => [ + 'application/json', + ], + 'getOfferMappings_1' => [ + 'application/json', + ], + 'getOfferRecommendations_1' => [ + 'application/json', + ], + 'getOffers_3' => [ + 'application/json', + ], + 'getOrderBusinessBuyerInfo_1' => [ + 'application/json', + ], + 'getOrderBusinessDocumentsInfo_1' => [ + 'application/json', + ], + 'getOrder_0' => [ + 'application/json', + ], + 'getOrdersStats_0' => [ + 'application/json', + ], + 'getOrders_2' => [ + 'application/json', + ], + 'getPricesByOfferIds_0' => [ + 'application/json', + ], + 'getPrices_0' => [ + 'application/json', + ], + 'getPromoOffers_0' => [ + 'application/json', + ], + 'getPromos_0' => [ + 'application/json', + ], + 'getQualityRatings_0' => [ + 'application/json', + ], + 'getReportInfo_0' => [ + 'application/json', + ], + 'getReturnPhoto_3' => [ + 'application/json', + ], + 'getReturn_3' => [ + 'application/json', + ], + 'getReturns_3' => [ + 'application/json', + ], + 'getStocks_0' => [ + 'application/json', + ], + 'getSuggestedOfferMappingEntries_0' => [ + 'application/json', + ], + 'getSuggestedOfferMappings_1' => [ + 'application/json', + ], + 'getSuggestedPrices_0' => [ + 'application/json', + ], + 'putBidsForBusiness_2' => [ + 'application/json', + ], + 'putBidsForCampaign_3' => [ + 'application/json', + ], + 'refreshFeed_3' => [ + 'application/json', + ], + 'searchRegionChildren_0' => [ + 'application/json', + ], + 'searchRegionsById_0' => [ + 'application/json', + ], + 'searchRegionsByName_0' => [ + 'application/json', + ], + 'sendFileToChat_2' => [ + 'multipart/form-data', + ], + 'sendMessageToChat_2' => [ + 'application/json', + ], + 'setFeedParams_3' => [ + 'application/json', + ], + 'skipGoodsFeedbacksReaction_0' => [ + 'application/json', + ], + 'updateBusinessPrices_0' => [ + 'application/json', + ], + 'updateCampaignOffers_1' => [ + 'application/json', + ], + 'updateGoodsFeedbackComment_0' => [ + 'application/json', + ], + 'updateOfferContent_1' => [ + 'application/json', + ], + 'updateOfferMappingEntries_0' => [ + 'application/json', + ], + 'updateOfferMappings_1' => [ + 'application/json', + ], + 'updatePrices_0' => [ + 'application/json', + ], + 'updatePromoOffers_0' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addHiddenOffers_0 + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addHiddenOffers_0($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_0'][0]) + { + list($response) = $this->addHiddenOffers_0WithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation addHiddenOffers_0WithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addHiddenOffers_0WithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_0'][0]) + { + $request = $this->addHiddenOffers_0Request($campaign_id, $add_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addHiddenOffers_0Async + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffers_0Async($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_0'][0]) + { + return $this->addHiddenOffers_0AsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addHiddenOffers_0AsyncWithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffers_0AsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->addHiddenOffers_0Request($campaign_id, $add_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addHiddenOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addHiddenOffers_0Request($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling addHiddenOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.addHiddenOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_hidden_offers_request' is set + if ($add_hidden_offers_request === null || (is_array($add_hidden_offers_request) && count($add_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_hidden_offers_request when calling addHiddenOffers_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_hidden_offers_request)); + } else { + $httpBody = $add_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation addOffersToArchive_1 + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addOffersToArchive_1($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_1'][0]) + { + list($response) = $this->addOffersToArchive_1WithHttpInfo($business_id, $add_offers_to_archive_request, $contentType); + return $response; + } + + /** + * Operation addOffersToArchive_1WithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\AddOffersToArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addOffersToArchive_1WithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_1'][0]) + { + $request = $this->addOffersToArchive_1Request($business_id, $add_offers_to_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\AddOffersToArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\AddOffersToArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\AddOffersToArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addOffersToArchive_1Async + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchive_1Async($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_1'][0]) + { + return $this->addOffersToArchive_1AsyncWithHttpInfo($business_id, $add_offers_to_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addOffersToArchive_1AsyncWithHttpInfo + * + * Добавление товаров в архив + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addOffersToArchive_1AsyncWithHttpInfo($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\AddOffersToArchiveResponse'; + $request = $this->addOffersToArchive_1Request($business_id, $add_offers_to_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addOffersToArchive_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddOffersToArchiveRequest $add_offers_to_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addOffersToArchive_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addOffersToArchive_1Request($business_id, $add_offers_to_archive_request, string $contentType = self::contentTypes['addOffersToArchive_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling addOffersToArchive_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.addOffersToArchive_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_offers_to_archive_request' is set + if ($add_offers_to_archive_request === null || (is_array($add_offers_to_archive_request) && count($add_offers_to_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_offers_to_archive_request when calling addOffersToArchive_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/archive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_offers_to_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_offers_to_archive_request)); + } else { + $httpBody = $add_offers_to_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation calculateTariffs_1 + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function calculateTariffs_1($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_1'][0]) + { + list($response) = $this->calculateTariffs_1WithHttpInfo($calculate_tariffs_request, $contentType); + return $response; + } + + /** + * Operation calculateTariffs_1WithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function calculateTariffs_1WithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_1'][0]) + { + $request = $this->calculateTariffs_1Request($calculate_tariffs_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CalculateTariffsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CalculateTariffsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation calculateTariffs_1Async + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffs_1Async($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_1'][0]) + { + return $this->calculateTariffs_1AsyncWithHttpInfo($calculate_tariffs_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation calculateTariffs_1AsyncWithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffs_1AsyncWithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + $request = $this->calculateTariffs_1Request($calculate_tariffs_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'calculateTariffs_1' + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function calculateTariffs_1Request($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs_1'][0]) + { + + // verify the required parameter 'calculate_tariffs_request' is set + if ($calculate_tariffs_request === null || (is_array($calculate_tariffs_request) && count($calculate_tariffs_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $calculate_tariffs_request when calling calculateTariffs_1' + ); + } + + + $resourcePath = '/tariffs/calculate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($calculate_tariffs_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($calculate_tariffs_request)); + } else { + $httpBody = $calculate_tariffs_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmBusinessPrices_1 + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmBusinessPrices_1($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_1'][0]) + { + list($response) = $this->confirmBusinessPrices_1WithHttpInfo($business_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmBusinessPrices_1WithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmBusinessPrices_1WithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_1'][0]) + { + $request = $this->confirmBusinessPrices_1Request($business_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmBusinessPrices_1Async + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPrices_1Async($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_1'][0]) + { + return $this->confirmBusinessPrices_1AsyncWithHttpInfo($business_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmBusinessPrices_1AsyncWithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPrices_1AsyncWithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmBusinessPrices_1Request($business_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmBusinessPrices_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmBusinessPrices_1Request($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling confirmBusinessPrices_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.confirmBusinessPrices_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmBusinessPrices_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmCampaignPrices_1 + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmCampaignPrices_1($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_1'][0]) + { + list($response) = $this->confirmCampaignPrices_1WithHttpInfo($campaign_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmCampaignPrices_1WithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmCampaignPrices_1WithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_1'][0]) + { + $request = $this->confirmCampaignPrices_1Request($campaign_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmCampaignPrices_1Async + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPrices_1Async($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_1'][0]) + { + return $this->confirmCampaignPrices_1AsyncWithHttpInfo($campaign_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmCampaignPrices_1AsyncWithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPrices_1AsyncWithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmCampaignPrices_1Request($campaign_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmCampaignPrices_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmCampaignPrices_1Request($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling confirmCampaignPrices_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.confirmCampaignPrices_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmCampaignPrices_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation createChat_2 + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function createChat_2($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_2'][0]) + { + list($response) = $this->createChat_2WithHttpInfo($business_id, $create_chat_request, $contentType); + return $response; + } + + /** + * Operation createChat_2WithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CreateChatResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function createChat_2WithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_2'][0]) + { + $request = $this->createChat_2Request($business_id, $create_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CreateChatResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CreateChatResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CreateChatResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CreateChatResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createChat_2Async + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChat_2Async($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_2'][0]) + { + return $this->createChat_2AsyncWithHttpInfo($business_id, $create_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createChat_2AsyncWithHttpInfo + * + * Создание нового чата с покупателем + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createChat_2AsyncWithHttpInfo($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\CreateChatResponse'; + $request = $this->createChat_2Request($business_id, $create_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createChat_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\CreateChatRequest $create_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createChat_2Request($business_id, $create_chat_request, string $contentType = self::contentTypes['createChat_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling createChat_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.createChat_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'create_chat_request' is set + if ($create_chat_request === null || (is_array($create_chat_request) && count($create_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $create_chat_request when calling createChat_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/new'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($create_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($create_chat_request)); + } else { + $httpBody = $create_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteCampaignOffers_1 + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteCampaignOffers_1($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_1'][0]) + { + list($response) = $this->deleteCampaignOffers_1WithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteCampaignOffers_1WithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteCampaignOffers_1WithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_1'][0]) + { + $request = $this->deleteCampaignOffers_1Request($campaign_id, $delete_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteCampaignOffers_1Async + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffers_1Async($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_1'][0]) + { + return $this->deleteCampaignOffers_1AsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteCampaignOffers_1AsyncWithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffers_1AsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + $request = $this->deleteCampaignOffers_1Request($campaign_id, $delete_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteCampaignOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteCampaignOffers_1Request($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteCampaignOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.deleteCampaignOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_campaign_offers_request' is set + if ($delete_campaign_offers_request === null || (is_array($delete_campaign_offers_request) && count($delete_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_campaign_offers_request when calling deleteCampaignOffers_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_campaign_offers_request)); + } else { + $httpBody = $delete_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteGoodsFeedbackComment_0 + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteGoodsFeedbackComment_0($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_0'][0]) + { + list($response) = $this->deleteGoodsFeedbackComment_0WithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation deleteGoodsFeedbackComment_0WithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteGoodsFeedbackComment_0WithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_0'][0]) + { + $request = $this->deleteGoodsFeedbackComment_0Request($business_id, $delete_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteGoodsFeedbackComment_0Async + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackComment_0Async($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_0'][0]) + { + return $this->deleteGoodsFeedbackComment_0AsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteGoodsFeedbackComment_0AsyncWithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackComment_0AsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteGoodsFeedbackComment_0Request($business_id, $delete_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteGoodsFeedbackComment_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteGoodsFeedbackComment_0Request($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteGoodsFeedbackComment_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.deleteGoodsFeedbackComment_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_goods_feedback_comment_request' is set + if ($delete_goods_feedback_comment_request === null || (is_array($delete_goods_feedback_comment_request) && count($delete_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_goods_feedback_comment_request when calling deleteGoodsFeedbackComment_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_goods_feedback_comment_request)); + } else { + $httpBody = $delete_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteHiddenOffers_0 + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteHiddenOffers_0($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_0'][0]) + { + list($response) = $this->deleteHiddenOffers_0WithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteHiddenOffers_0WithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteHiddenOffers_0WithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_0'][0]) + { + $request = $this->deleteHiddenOffers_0Request($campaign_id, $delete_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteHiddenOffers_0Async + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffers_0Async($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_0'][0]) + { + return $this->deleteHiddenOffers_0AsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteHiddenOffers_0AsyncWithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffers_0AsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteHiddenOffers_0Request($campaign_id, $delete_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteHiddenOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteHiddenOffers_0Request($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteHiddenOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.deleteHiddenOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_hidden_offers_request' is set + if ($delete_hidden_offers_request === null || (is_array($delete_hidden_offers_request) && count($delete_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_hidden_offers_request when calling deleteHiddenOffers_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_hidden_offers_request)); + } else { + $httpBody = $delete_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffersFromArchive_1 + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffersFromArchive_1($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_1'][0]) + { + list($response) = $this->deleteOffersFromArchive_1WithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType); + return $response; + } + + /** + * Operation deleteOffersFromArchive_1WithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersFromArchiveResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffersFromArchive_1WithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_1'][0]) + { + $request = $this->deleteOffersFromArchive_1Request($business_id, $delete_offers_from_archive_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffersFromArchive_1Async + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchive_1Async($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_1'][0]) + { + return $this->deleteOffersFromArchive_1AsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffersFromArchive_1AsyncWithHttpInfo + * + * Удаление товаров из архива + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffersFromArchive_1AsyncWithHttpInfo($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersFromArchiveResponse'; + $request = $this->deleteOffersFromArchive_1Request($business_id, $delete_offers_from_archive_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffersFromArchive_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveRequest $delete_offers_from_archive_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffersFromArchive_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffersFromArchive_1Request($business_id, $delete_offers_from_archive_request, string $contentType = self::contentTypes['deleteOffersFromArchive_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffersFromArchive_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.deleteOffersFromArchive_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_from_archive_request' is set + if ($delete_offers_from_archive_request === null || (is_array($delete_offers_from_archive_request) && count($delete_offers_from_archive_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_from_archive_request when calling deleteOffersFromArchive_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/unarchive'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_from_archive_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_from_archive_request)); + } else { + $httpBody = $delete_offers_from_archive_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOffers_1 + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOffers_1($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_1'][0]) + { + list($response) = $this->deleteOffers_1WithHttpInfo($business_id, $delete_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteOffers_1WithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOffers_1WithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_1'][0]) + { + $request = $this->deleteOffers_1Request($business_id, $delete_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOffers_1Async + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffers_1Async($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_1'][0]) + { + return $this->deleteOffers_1AsyncWithHttpInfo($business_id, $delete_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOffers_1AsyncWithHttpInfo + * + * Удаление товаров из каталога + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOffers_1AsyncWithHttpInfo($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteOffersResponse'; + $request = $this->deleteOffers_1Request($business_id, $delete_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOffers_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteOffersRequest $delete_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOffers_1Request($business_id, $delete_offers_request, string $contentType = self::contentTypes['deleteOffers_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteOffers_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.deleteOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_offers_request' is set + if ($delete_offers_request === null || (is_array($delete_offers_request) && count($delete_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_offers_request when calling deleteOffers_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_offers_request)); + } else { + $httpBody = $delete_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deletePromoOffers_0 + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deletePromoOffers_0($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_0'][0]) + { + list($response) = $this->deletePromoOffers_0WithHttpInfo($business_id, $delete_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation deletePromoOffers_0WithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deletePromoOffers_0WithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_0'][0]) + { + $request = $this->deletePromoOffers_0Request($business_id, $delete_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeletePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeletePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deletePromoOffers_0Async + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffers_0Async($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_0'][0]) + { + return $this->deletePromoOffers_0AsyncWithHttpInfo($business_id, $delete_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deletePromoOffers_0AsyncWithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffers_0AsyncWithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + $request = $this->deletePromoOffers_0Request($business_id, $delete_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePromoOffers_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deletePromoOffers_0Request($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deletePromoOffers_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.deletePromoOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_promo_offers_request' is set + if ($delete_promo_offers_request === null || (is_array($delete_promo_offers_request) && count($delete_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_promo_offers_request when calling deletePromoOffers_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_promo_offers_request)); + } else { + $httpBody = $delete_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateBoostConsolidatedReport_0 + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateBoostConsolidatedReport_0($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_0'][0]) + { + list($response) = $this->generateBoostConsolidatedReport_0WithHttpInfo($generate_boost_consolidated_request, $format, $contentType); + return $response; + } + + /** + * Operation generateBoostConsolidatedReport_0WithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateBoostConsolidatedReport_0WithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_0'][0]) + { + $request = $this->generateBoostConsolidatedReport_0Request($generate_boost_consolidated_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateBoostConsolidatedReport_0Async + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReport_0Async($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_0'][0]) + { + return $this->generateBoostConsolidatedReport_0AsyncWithHttpInfo($generate_boost_consolidated_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateBoostConsolidatedReport_0AsyncWithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReport_0AsyncWithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateBoostConsolidatedReport_0Request($generate_boost_consolidated_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateBoostConsolidatedReport_0' + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateBoostConsolidatedReport_0Request($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport_0'][0]) + { + + // verify the required parameter 'generate_boost_consolidated_request' is set + if ($generate_boost_consolidated_request === null || (is_array($generate_boost_consolidated_request) && count($generate_boost_consolidated_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_boost_consolidated_request when calling generateBoostConsolidatedReport_0' + ); + } + + + + $resourcePath = '/reports/boost-consolidated/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_boost_consolidated_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_boost_consolidated_request)); + } else { + $httpBody = $generate_boost_consolidated_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateCompetitorsPositionReport_0 + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateCompetitorsPositionReport_0($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_0'][0]) + { + list($response) = $this->generateCompetitorsPositionReport_0WithHttpInfo($generate_competitors_position_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateCompetitorsPositionReport_0WithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateCompetitorsPositionReport_0WithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_0'][0]) + { + $request = $this->generateCompetitorsPositionReport_0Request($generate_competitors_position_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateCompetitorsPositionReport_0Async + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReport_0Async($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_0'][0]) + { + return $this->generateCompetitorsPositionReport_0AsyncWithHttpInfo($generate_competitors_position_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateCompetitorsPositionReport_0AsyncWithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReport_0AsyncWithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateCompetitorsPositionReport_0Request($generate_competitors_position_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateCompetitorsPositionReport_0' + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateCompetitorsPositionReport_0Request($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport_0'][0]) + { + + // verify the required parameter 'generate_competitors_position_report_request' is set + if ($generate_competitors_position_report_request === null || (is_array($generate_competitors_position_report_request) && count($generate_competitors_position_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_competitors_position_report_request when calling generateCompetitorsPositionReport_0' + ); + } + + + + $resourcePath = '/reports/competitors-position/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_competitors_position_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_competitors_position_report_request)); + } else { + $httpBody = $generate_competitors_position_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsFeedbackReport_0 + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsFeedbackReport_0($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_0'][0]) + { + list($response) = $this->generateGoodsFeedbackReport_0WithHttpInfo($generate_goods_feedback_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsFeedbackReport_0WithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsFeedbackReport_0WithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_0'][0]) + { + $request = $this->generateGoodsFeedbackReport_0Request($generate_goods_feedback_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsFeedbackReport_0Async + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReport_0Async($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_0'][0]) + { + return $this->generateGoodsFeedbackReport_0AsyncWithHttpInfo($generate_goods_feedback_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsFeedbackReport_0AsyncWithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReport_0AsyncWithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsFeedbackReport_0Request($generate_goods_feedback_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsFeedbackReport_0' + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsFeedbackReport_0Request($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport_0'][0]) + { + + // verify the required parameter 'generate_goods_feedback_request' is set + if ($generate_goods_feedback_request === null || (is_array($generate_goods_feedback_request) && count($generate_goods_feedback_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_feedback_request when calling generateGoodsFeedbackReport_0' + ); + } + + + + $resourcePath = '/reports/goods-feedback/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_feedback_request)); + } else { + $httpBody = $generate_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsMovementReport_0 + * + * Отчет по движению товаров + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsMovementReport_0($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport_0'][0]) + { + list($response) = $this->generateGoodsMovementReport_0WithHttpInfo($generate_goods_movement_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsMovementReport_0WithHttpInfo + * + * Отчет по движению товаров + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsMovementReport_0WithHttpInfo($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport_0'][0]) + { + $request = $this->generateGoodsMovementReport_0Request($generate_goods_movement_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsMovementReport_0Async + * + * Отчет по движению товаров + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsMovementReport_0Async($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport_0'][0]) + { + return $this->generateGoodsMovementReport_0AsyncWithHttpInfo($generate_goods_movement_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsMovementReport_0AsyncWithHttpInfo + * + * Отчет по движению товаров + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsMovementReport_0AsyncWithHttpInfo($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsMovementReport_0Request($generate_goods_movement_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsMovementReport_0' + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsMovementReport_0Request($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport_0'][0]) + { + + // verify the required parameter 'generate_goods_movement_report_request' is set + if ($generate_goods_movement_report_request === null || (is_array($generate_goods_movement_report_request) && count($generate_goods_movement_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_movement_report_request when calling generateGoodsMovementReport_0' + ); + } + + + + $resourcePath = '/reports/goods-movement/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_movement_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_movement_report_request)); + } else { + $httpBody = $generate_goods_movement_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsRealizationReport_0 + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsRealizationReport_0($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_0'][0]) + { + list($response) = $this->generateGoodsRealizationReport_0WithHttpInfo($generate_goods_realization_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsRealizationReport_0WithHttpInfo + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsRealizationReport_0WithHttpInfo($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_0'][0]) + { + $request = $this->generateGoodsRealizationReport_0Request($generate_goods_realization_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsRealizationReport_0Async + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsRealizationReport_0Async($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_0'][0]) + { + return $this->generateGoodsRealizationReport_0AsyncWithHttpInfo($generate_goods_realization_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsRealizationReport_0AsyncWithHttpInfo + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsRealizationReport_0AsyncWithHttpInfo($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsRealizationReport_0Request($generate_goods_realization_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsRealizationReport_0' + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsRealizationReport_0Request($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport_0'][0]) + { + + // verify the required parameter 'generate_goods_realization_report_request' is set + if ($generate_goods_realization_report_request === null || (is_array($generate_goods_realization_report_request) && count($generate_goods_realization_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_realization_report_request when calling generateGoodsRealizationReport_0' + ); + } + + + + $resourcePath = '/reports/goods-realization/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_realization_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_realization_report_request)); + } else { + $httpBody = $generate_goods_realization_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsTurnoverReport_0 + * + * Отчет по оборачиваемости + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsTurnoverReport_0($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport_0'][0]) + { + list($response) = $this->generateGoodsTurnoverReport_0WithHttpInfo($generate_goods_turnover_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsTurnoverReport_0WithHttpInfo + * + * Отчет по оборачиваемости + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsTurnoverReport_0WithHttpInfo($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport_0'][0]) + { + $request = $this->generateGoodsTurnoverReport_0Request($generate_goods_turnover_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsTurnoverReport_0Async + * + * Отчет по оборачиваемости + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsTurnoverReport_0Async($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport_0'][0]) + { + return $this->generateGoodsTurnoverReport_0AsyncWithHttpInfo($generate_goods_turnover_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsTurnoverReport_0AsyncWithHttpInfo + * + * Отчет по оборачиваемости + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsTurnoverReport_0AsyncWithHttpInfo($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsTurnoverReport_0Request($generate_goods_turnover_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsTurnoverReport_0' + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsTurnoverReport_0Request($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport_0'][0]) + { + + // verify the required parameter 'generate_goods_turnover_request' is set + if ($generate_goods_turnover_request === null || (is_array($generate_goods_turnover_request) && count($generate_goods_turnover_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_turnover_request when calling generateGoodsTurnoverReport_0' + ); + } + + + + $resourcePath = '/reports/goods-turnover/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_turnover_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_turnover_request)); + } else { + $httpBody = $generate_goods_turnover_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generatePricesReport_0 + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generatePricesReport_0($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_0'][0]) + { + list($response) = $this->generatePricesReport_0WithHttpInfo($generate_prices_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generatePricesReport_0WithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generatePricesReport_0WithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_0'][0]) + { + $request = $this->generatePricesReport_0Request($generate_prices_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generatePricesReport_0Async + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReport_0Async($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_0'][0]) + { + return $this->generatePricesReport_0AsyncWithHttpInfo($generate_prices_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generatePricesReport_0AsyncWithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReport_0AsyncWithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generatePricesReport_0Request($generate_prices_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generatePricesReport_0' + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generatePricesReport_0Request($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport_0'][0]) + { + + // verify the required parameter 'generate_prices_report_request' is set + if ($generate_prices_report_request === null || (is_array($generate_prices_report_request) && count($generate_prices_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_prices_report_request when calling generatePricesReport_0' + ); + } + + + + $resourcePath = '/reports/prices/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_prices_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_prices_report_request)); + } else { + $httpBody = $generate_prices_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShelfsStatisticsReport_0 + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShelfsStatisticsReport_0($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_0'][0]) + { + list($response) = $this->generateShelfsStatisticsReport_0WithHttpInfo($generate_shelfs_statistics_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShelfsStatisticsReport_0WithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShelfsStatisticsReport_0WithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_0'][0]) + { + $request = $this->generateShelfsStatisticsReport_0Request($generate_shelfs_statistics_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShelfsStatisticsReport_0Async + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReport_0Async($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_0'][0]) + { + return $this->generateShelfsStatisticsReport_0AsyncWithHttpInfo($generate_shelfs_statistics_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShelfsStatisticsReport_0AsyncWithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReport_0AsyncWithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShelfsStatisticsReport_0Request($generate_shelfs_statistics_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShelfsStatisticsReport_0' + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShelfsStatisticsReport_0Request($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport_0'][0]) + { + + // verify the required parameter 'generate_shelfs_statistics_request' is set + if ($generate_shelfs_statistics_request === null || (is_array($generate_shelfs_statistics_request) && count($generate_shelfs_statistics_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shelfs_statistics_request when calling generateShelfsStatisticsReport_0' + ); + } + + + + $resourcePath = '/reports/shelf-statistics/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shelfs_statistics_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shelfs_statistics_request)); + } else { + $httpBody = $generate_shelfs_statistics_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShowsSalesReport_0 + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShowsSalesReport_0($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_0'][0]) + { + list($response) = $this->generateShowsSalesReport_0WithHttpInfo($generate_shows_sales_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShowsSalesReport_0WithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShowsSalesReport_0WithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_0'][0]) + { + $request = $this->generateShowsSalesReport_0Request($generate_shows_sales_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShowsSalesReport_0Async + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReport_0Async($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_0'][0]) + { + return $this->generateShowsSalesReport_0AsyncWithHttpInfo($generate_shows_sales_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShowsSalesReport_0AsyncWithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReport_0AsyncWithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShowsSalesReport_0Request($generate_shows_sales_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShowsSalesReport_0' + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShowsSalesReport_0Request($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport_0'][0]) + { + + // verify the required parameter 'generate_shows_sales_report_request' is set + if ($generate_shows_sales_report_request === null || (is_array($generate_shows_sales_report_request) && count($generate_shows_sales_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shows_sales_report_request when calling generateShowsSalesReport_0' + ); + } + + + + $resourcePath = '/reports/shows-sales/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shows_sales_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shows_sales_report_request)); + } else { + $httpBody = $generate_shows_sales_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateStocksOnWarehousesReport_0 + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateStocksOnWarehousesReport_0($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_0'][0]) + { + list($response) = $this->generateStocksOnWarehousesReport_0WithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateStocksOnWarehousesReport_0WithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateStocksOnWarehousesReport_0WithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_0'][0]) + { + $request = $this->generateStocksOnWarehousesReport_0Request($generate_stocks_on_warehouses_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateStocksOnWarehousesReport_0Async + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReport_0Async($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_0'][0]) + { + return $this->generateStocksOnWarehousesReport_0AsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateStocksOnWarehousesReport_0AsyncWithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReport_0AsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateStocksOnWarehousesReport_0Request($generate_stocks_on_warehouses_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateStocksOnWarehousesReport_0' + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateStocksOnWarehousesReport_0Request($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport_0'][0]) + { + + // verify the required parameter 'generate_stocks_on_warehouses_report_request' is set + if ($generate_stocks_on_warehouses_report_request === null || (is_array($generate_stocks_on_warehouses_report_request) && count($generate_stocks_on_warehouses_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_stocks_on_warehouses_report_request when calling generateStocksOnWarehousesReport_0' + ); + } + + + + $resourcePath = '/reports/stocks-on-warehouses/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_stocks_on_warehouses_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_stocks_on_warehouses_report_request)); + } else { + $httpBody = $generate_stocks_on_warehouses_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport_0 + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedMarketplaceServicesReport_0($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_0'][0]) + { + list($response) = $this->generateUnitedMarketplaceServicesReport_0WithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedMarketplaceServicesReport_0WithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedMarketplaceServicesReport_0WithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_0'][0]) + { + $request = $this->generateUnitedMarketplaceServicesReport_0Request($generate_united_marketplace_services_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedMarketplaceServicesReport_0Async + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReport_0Async($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_0'][0]) + { + return $this->generateUnitedMarketplaceServicesReport_0AsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport_0AsyncWithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReport_0AsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedMarketplaceServicesReport_0Request($generate_united_marketplace_services_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedMarketplaceServicesReport_0' + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedMarketplaceServicesReport_0Request($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport_0'][0]) + { + + // verify the required parameter 'generate_united_marketplace_services_report_request' is set + if ($generate_united_marketplace_services_report_request === null || (is_array($generate_united_marketplace_services_report_request) && count($generate_united_marketplace_services_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_marketplace_services_report_request when calling generateUnitedMarketplaceServicesReport_0' + ); + } + + + + $resourcePath = '/reports/united-marketplace-services/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_marketplace_services_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_marketplace_services_report_request)); + } else { + $httpBody = $generate_united_marketplace_services_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedNettingReport_0 + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedNettingReport_0($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_0'][0]) + { + list($response) = $this->generateUnitedNettingReport_0WithHttpInfo($generate_united_netting_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedNettingReport_0WithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedNettingReport_0WithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_0'][0]) + { + $request = $this->generateUnitedNettingReport_0Request($generate_united_netting_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedNettingReport_0Async + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReport_0Async($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_0'][0]) + { + return $this->generateUnitedNettingReport_0AsyncWithHttpInfo($generate_united_netting_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedNettingReport_0AsyncWithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReport_0AsyncWithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedNettingReport_0Request($generate_united_netting_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedNettingReport_0' + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedNettingReport_0Request($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport_0'][0]) + { + + // verify the required parameter 'generate_united_netting_report_request' is set + if ($generate_united_netting_report_request === null || (is_array($generate_united_netting_report_request) && count($generate_united_netting_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_netting_report_request when calling generateUnitedNettingReport_0' + ); + } + + + + $resourcePath = '/reports/united-netting/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_netting_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_netting_report_request)); + } else { + $httpBody = $generate_united_netting_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedOrdersReport_0 + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedOrdersReport_0($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_0'][0]) + { + list($response) = $this->generateUnitedOrdersReport_0WithHttpInfo($generate_united_orders_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedOrdersReport_0WithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedOrdersReport_0WithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_0'][0]) + { + $request = $this->generateUnitedOrdersReport_0Request($generate_united_orders_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedOrdersReport_0Async + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReport_0Async($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_0'][0]) + { + return $this->generateUnitedOrdersReport_0AsyncWithHttpInfo($generate_united_orders_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedOrdersReport_0AsyncWithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReport_0AsyncWithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedOrdersReport_0Request($generate_united_orders_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedOrdersReport_0' + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedOrdersReport_0Request($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport_0'][0]) + { + + // verify the required parameter 'generate_united_orders_request' is set + if ($generate_united_orders_request === null || (is_array($generate_united_orders_request) && count($generate_united_orders_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_orders_request when calling generateUnitedOrdersReport_0' + ); + } + + + + $resourcePath = '/reports/united-orders/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_orders_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_orders_request)); + } else { + $httpBody = $generate_united_orders_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getAllOffers_3 + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getAllOffers_3($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_3'][0]) + { + list($response) = $this->getAllOffers_3WithHttpInfo($campaign_id, $feed_id, $chunk, $contentType); + return $response; + } + + /** + * Operation getAllOffers_3WithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getAllOffers_3WithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_3'][0]) + { + $request = $this->getAllOffers_3Request($campaign_id, $feed_id, $chunk, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetAllOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetAllOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetAllOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetAllOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getAllOffers_3Async + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffers_3Async($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_3'][0]) + { + return $this->getAllOffers_3AsyncWithHttpInfo($campaign_id, $feed_id, $chunk, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getAllOffers_3AsyncWithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffers_3AsyncWithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + $request = $this->getAllOffers_3Request($campaign_id, $feed_id, $chunk, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getAllOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getAllOffers_3Request($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getAllOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getAllOffers_3, must be bigger than or equal to 1.'); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers/all'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chunk, + 'chunk', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsInfoForBusiness_2 + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsInfoForBusiness_2($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_2'][0]) + { + list($response) = $this->getBidsInfoForBusiness_2WithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + return $response; + } + + /** + * Operation getBidsInfoForBusiness_2WithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsInfoForBusiness_2WithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_2'][0]) + { + $request = $this->getBidsInfoForBusiness_2Request($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsInfoForBusiness_2Async + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusiness_2Async($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_2'][0]) + { + return $this->getBidsInfoForBusiness_2AsyncWithHttpInfo($business_id, $page_token, $limit, $get_bids_info_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsInfoForBusiness_2AsyncWithHttpInfo + * + * Информация об установленных ставках + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsInfoForBusiness_2AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsInfoResponse'; + $request = $this->getBidsInfoForBusiness_2Request($business_id, $page_token, $limit, $get_bids_info_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsInfoForBusiness_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetBidsInfoRequest $get_bids_info_request description (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsInfoForBusiness_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsInfoForBusiness_2Request($business_id, $page_token = null, $limit = null, $get_bids_info_request = null, string $contentType = self::contentTypes['getBidsInfoForBusiness_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsInfoForBusiness_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getBidsInfoForBusiness_2, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/bids/info'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_info_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_info_request)); + } else { + $httpBody = $get_bids_info_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBidsRecommendations_2 + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBidsRecommendations_2($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_2'][0]) + { + list($response) = $this->getBidsRecommendations_2WithHttpInfo($business_id, $get_bids_recommendations_request, $contentType); + return $response; + } + + /** + * Operation getBidsRecommendations_2WithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBidsRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBidsRecommendations_2WithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_2'][0]) + { + $request = $this->getBidsRecommendations_2Request($business_id, $get_bids_recommendations_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBidsRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBidsRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBidsRecommendations_2Async + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendations_2Async($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_2'][0]) + { + return $this->getBidsRecommendations_2AsyncWithHttpInfo($business_id, $get_bids_recommendations_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBidsRecommendations_2AsyncWithHttpInfo + * + * Рекомендованные ставки для заданных товаров + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBidsRecommendations_2AsyncWithHttpInfo($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBidsRecommendationsResponse'; + $request = $this->getBidsRecommendations_2Request($business_id, $get_bids_recommendations_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBidsRecommendations_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetBidsRecommendationsRequest $get_bids_recommendations_request description. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBidsRecommendations_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBidsRecommendations_2Request($business_id, $get_bids_recommendations_request, string $contentType = self::contentTypes['getBidsRecommendations_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBidsRecommendations_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getBidsRecommendations_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_bids_recommendations_request' is set + if ($get_bids_recommendations_request === null || (is_array($get_bids_recommendations_request) && count($get_bids_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_bids_recommendations_request when calling getBidsRecommendations_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_bids_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_bids_recommendations_request)); + } else { + $httpBody = $get_bids_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessQuarantineOffers_1 + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessQuarantineOffers_1($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_1'][0]) + { + list($response) = $this->getBusinessQuarantineOffers_1WithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getBusinessQuarantineOffers_1WithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessQuarantineOffers_1WithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_1'][0]) + { + $request = $this->getBusinessQuarantineOffers_1Request($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessQuarantineOffers_1Async + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffers_1Async($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_1'][0]) + { + return $this->getBusinessQuarantineOffers_1AsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessQuarantineOffers_1AsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffers_1AsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getBusinessQuarantineOffers_1Request($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessQuarantineOffers_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessQuarantineOffers_1Request($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessQuarantineOffers_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getBusinessQuarantineOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getBusinessQuarantineOffers_1' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessSettings_2 + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessSettings_2($business_id, string $contentType = self::contentTypes['getBusinessSettings_2'][0]) + { + list($response) = $this->getBusinessSettings_2WithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getBusinessSettings_2WithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessSettings_2WithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings_2'][0]) + { + $request = $this->getBusinessSettings_2Request($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessSettings_2Async + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettings_2Async($business_id, string $contentType = self::contentTypes['getBusinessSettings_2'][0]) + { + return $this->getBusinessSettings_2AsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessSettings_2AsyncWithHttpInfo + * + * Настройки кабинета + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessSettings_2AsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getBusinessSettings_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessSettingsResponse'; + $request = $this->getBusinessSettings_2Request($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessSettings_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessSettings_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessSettings_2Request($business_id, string $contentType = self::contentTypes['getBusinessSettings_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessSettings_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getBusinessSettings_2, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignLogins_3 + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignLogins_3($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_3'][0]) + { + list($response) = $this->getCampaignLogins_3WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignLogins_3WithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignLoginsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignLogins_3WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_3'][0]) + { + $request = $this->getCampaignLogins_3Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignLoginsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignLoginsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignLoginsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignLogins_3Async + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLogins_3Async($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_3'][0]) + { + return $this->getCampaignLogins_3AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignLogins_3AsyncWithHttpInfo + * + * Логины, связанные с магазином + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignLogins_3AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignLoginsResponse'; + $request = $this->getCampaignLogins_3Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignLogins_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignLogins_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignLogins_3Request($campaign_id, string $contentType = self::contentTypes['getCampaignLogins_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignLogins_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getCampaignLogins_3, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/logins'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignOffers_1 + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignOffers_1($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_1'][0]) + { + list($response) = $this->getCampaignOffers_1WithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignOffers_1WithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignOffers_1WithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_1'][0]) + { + $request = $this->getCampaignOffers_1Request($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignOffers_1Async + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffers_1Async($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_1'][0]) + { + return $this->getCampaignOffers_1AsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignOffers_1AsyncWithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffers_1AsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + $request = $this->getCampaignOffers_1Request($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignOffers_1Request($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getCampaignOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_campaign_offers_request' is set + if ($get_campaign_offers_request === null || (is_array($get_campaign_offers_request) && count($get_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_campaign_offers_request when calling getCampaignOffers_1' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_campaign_offers_request)); + } else { + $httpBody = $get_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignQuarantineOffers_1 + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignQuarantineOffers_1($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_1'][0]) + { + list($response) = $this->getCampaignQuarantineOffers_1WithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignQuarantineOffers_1WithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignQuarantineOffers_1WithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_1'][0]) + { + $request = $this->getCampaignQuarantineOffers_1Request($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignQuarantineOffers_1Async + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffers_1Async($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_1'][0]) + { + return $this->getCampaignQuarantineOffers_1AsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignQuarantineOffers_1AsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffers_1AsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getCampaignQuarantineOffers_1Request($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignQuarantineOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignQuarantineOffers_1Request($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignQuarantineOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getCampaignQuarantineOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getCampaignQuarantineOffers_1' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignRegion_1 + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getCampaignRegion_1($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_1'][0]) + { + list($response) = $this->getCampaignRegion_1WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignRegion_1WithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignRegionResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getCampaignRegion_1WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_1'][0]) + { + $request = $this->getCampaignRegion_1Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignRegionResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignRegionResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignRegionResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignRegion_1Async + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegion_1Async($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_1'][0]) + { + return $this->getCampaignRegion_1AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignRegion_1AsyncWithHttpInfo + * + * Регион магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getCampaignRegion_1AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignRegionResponse'; + $request = $this->getCampaignRegion_1Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignRegion_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignRegion_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getCampaignRegion_1Request($campaign_id, string $contentType = self::contentTypes['getCampaignRegion_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignRegion_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getCampaignRegion_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/region'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignSettings_3 + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignSettings_3($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_3'][0]) + { + list($response) = $this->getCampaignSettings_3WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaignSettings_3WithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignSettingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignSettings_3WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_3'][0]) + { + $request = $this->getCampaignSettings_3Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignSettingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignSettingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignSettingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignSettings_3Async + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettings_3Async($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_3'][0]) + { + return $this->getCampaignSettings_3AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignSettings_3AsyncWithHttpInfo + * + * Настройки магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignSettings_3AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignSettingsResponse'; + $request = $this->getCampaignSettings_3Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignSettings_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignSettings_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignSettings_3Request($campaign_id, string $contentType = self::contentTypes['getCampaignSettings_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignSettings_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getCampaignSettings_3, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/settings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaign_3 + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaign_3($campaign_id, string $contentType = self::contentTypes['getCampaign_3'][0]) + { + list($response) = $this->getCampaign_3WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getCampaign_3WithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaign_3WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign_3'][0]) + { + $request = $this->getCampaign_3Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaign_3Async + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaign_3Async($campaign_id, string $contentType = self::contentTypes['getCampaign_3'][0]) + { + return $this->getCampaign_3AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaign_3AsyncWithHttpInfo + * + * Информация о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaign_3AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getCampaign_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignResponse'; + $request = $this->getCampaign_3Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaign_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaign_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaign_3Request($campaign_id, string $contentType = self::contentTypes['getCampaign_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaign_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getCampaign_3, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignsByLogin_3 + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignsByLogin_3($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_3'][0]) + { + list($response) = $this->getCampaignsByLogin_3WithHttpInfo($login, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaignsByLogin_3WithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignsByLogin_3WithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_3'][0]) + { + $request = $this->getCampaignsByLogin_3Request($login, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignsByLogin_3Async + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLogin_3Async($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_3'][0]) + { + return $this->getCampaignsByLogin_3AsyncWithHttpInfo($login, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignsByLogin_3AsyncWithHttpInfo + * + * Магазины, доступные логину + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignsByLogin_3AsyncWithHttpInfo($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaignsByLogin_3Request($login, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignsByLogin_3' + * + * @param string $login Логин пользователя. (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignsByLogin_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignsByLogin_3Request($login, $page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaignsByLogin_3'][0]) + { + + // verify the required parameter 'login' is set + if ($login === null || (is_array($login) && count($login) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $login when calling getCampaignsByLogin_3' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbyApi.getCampaignsByLogin_3, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/by_login/{login}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($login !== null) { + $resourcePath = str_replace( + '{' . 'login' . '}', + ObjectSerializer::toPathValue($login), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaigns_3 + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaigns_3($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_3'][0]) + { + list($response) = $this->getCampaigns_3WithHttpInfo($page, $page_size, $contentType); + return $response; + } + + /** + * Operation getCampaigns_3WithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaigns_3WithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_3'][0]) + { + $request = $this->getCampaigns_3Request($page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaigns_3Async + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaigns_3Async($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_3'][0]) + { + return $this->getCampaigns_3AsyncWithHttpInfo($page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaigns_3AsyncWithHttpInfo + * + * Список магазинов пользователя + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaigns_3AsyncWithHttpInfo($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignsResponse'; + $request = $this->getCampaigns_3Request($page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaigns_3' + * + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaigns_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaigns_3Request($page = 1, $page_size = null, string $contentType = self::contentTypes['getCampaigns_3'][0]) + { + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbyApi.getCampaigns_3, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesMaxSaleQuantum_0 + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesMaxSaleQuantum_0($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_0'][0]) + { + list($response) = $this->getCategoriesMaxSaleQuantum_0WithHttpInfo($get_categories_max_sale_quantum_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesMaxSaleQuantum_0WithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesMaxSaleQuantum_0WithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_0'][0]) + { + $request = $this->getCategoriesMaxSaleQuantum_0Request($get_categories_max_sale_quantum_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesMaxSaleQuantum_0Async + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantum_0Async($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_0'][0]) + { + return $this->getCategoriesMaxSaleQuantum_0AsyncWithHttpInfo($get_categories_max_sale_quantum_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesMaxSaleQuantum_0AsyncWithHttpInfo + * + * Лимит на установку кванта продажи и минимального количества товаров в заказе + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesMaxSaleQuantum_0AsyncWithHttpInfo($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumResponse'; + $request = $this->getCategoriesMaxSaleQuantum_0Request($get_categories_max_sale_quantum_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesMaxSaleQuantum_0' + * + * @param \OpenAPI\Client\Model\GetCategoriesMaxSaleQuantumRequest $get_categories_max_sale_quantum_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesMaxSaleQuantum_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesMaxSaleQuantum_0Request($get_categories_max_sale_quantum_request, string $contentType = self::contentTypes['getCategoriesMaxSaleQuantum_0'][0]) + { + + // verify the required parameter 'get_categories_max_sale_quantum_request' is set + if ($get_categories_max_sale_quantum_request === null || (is_array($get_categories_max_sale_quantum_request) && count($get_categories_max_sale_quantum_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_categories_max_sale_quantum_request when calling getCategoriesMaxSaleQuantum_0' + ); + } + + + $resourcePath = '/categories/max-sale-quantum'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_max_sale_quantum_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_max_sale_quantum_request)); + } else { + $httpBody = $get_categories_max_sale_quantum_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoriesTree_0 + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoriesTree_0($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_0'][0]) + { + list($response) = $this->getCategoriesTree_0WithHttpInfo($get_categories_request, $contentType); + return $response; + } + + /** + * Operation getCategoriesTree_0WithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoriesTree_0WithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_0'][0]) + { + $request = $this->getCategoriesTree_0Request($get_categories_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoriesTree_0Async + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTree_0Async($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_0'][0]) + { + return $this->getCategoriesTree_0AsyncWithHttpInfo($get_categories_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoriesTree_0AsyncWithHttpInfo + * + * Дерево категорий + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoriesTree_0AsyncWithHttpInfo($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoriesResponse'; + $request = $this->getCategoriesTree_0Request($get_categories_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoriesTree_0' + * + * @param \OpenAPI\Client\Model\GetCategoriesRequest $get_categories_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoriesTree_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoriesTree_0Request($get_categories_request = null, string $contentType = self::contentTypes['getCategoriesTree_0'][0]) + { + + + + $resourcePath = '/categories/tree'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_categories_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_categories_request)); + } else { + $httpBody = $get_categories_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCategoryContentParameters_1 + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCategoryContentParameters_1($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_1'][0]) + { + list($response) = $this->getCategoryContentParameters_1WithHttpInfo($category_id, $contentType); + return $response; + } + + /** + * Operation getCategoryContentParameters_1WithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCategoryContentParametersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCategoryContentParameters_1WithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_1'][0]) + { + $request = $this->getCategoryContentParameters_1Request($category_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCategoryContentParametersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCategoryContentParametersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCategoryContentParameters_1Async + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParameters_1Async($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_1'][0]) + { + return $this->getCategoryContentParameters_1AsyncWithHttpInfo($category_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCategoryContentParameters_1AsyncWithHttpInfo + * + * Списки характеристик товаров по категориям + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCategoryContentParameters_1AsyncWithHttpInfo($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCategoryContentParametersResponse'; + $request = $this->getCategoryContentParameters_1Request($category_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCategoryContentParameters_1' + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится интересующий вас товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCategoryContentParameters_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCategoryContentParameters_1Request($category_id, string $contentType = self::contentTypes['getCategoryContentParameters_1'][0]) + { + + // verify the required parameter 'category_id' is set + if ($category_id === null || (is_array($category_id) && count($category_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $category_id when calling getCategoryContentParameters_1' + ); + } + if ($category_id < 1) { + throw new \InvalidArgumentException('invalid value for "$category_id" when calling FbyApi.getCategoryContentParameters_1, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/category/{categoryId}/parameters'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($category_id !== null) { + $resourcePath = str_replace( + '{' . 'categoryId' . '}', + ObjectSerializer::toPathValue($category_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChatHistory_2 + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChatHistory_2($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_2'][0]) + { + list($response) = $this->getChatHistory_2WithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChatHistory_2WithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatHistoryResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChatHistory_2WithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_2'][0]) + { + $request = $this->getChatHistory_2Request($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatHistoryResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatHistoryResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatHistoryResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChatHistory_2Async + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistory_2Async($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_2'][0]) + { + return $this->getChatHistory_2AsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChatHistory_2AsyncWithHttpInfo + * + * Получение истории сообщений в чате + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChatHistory_2AsyncWithHttpInfo($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatHistoryResponse'; + $request = $this->getChatHistory_2Request($business_id, $chat_id, $get_chat_history_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChatHistory_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\GetChatHistoryRequest $get_chat_history_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChatHistory_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChatHistory_2Request($business_id, $chat_id, $get_chat_history_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChatHistory_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChatHistory_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getChatHistory_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling getChatHistory_2' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling FbyApi.getChatHistory_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chat_history_request' is set + if ($get_chat_history_request === null || (is_array($get_chat_history_request) && count($get_chat_history_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chat_history_request when calling getChatHistory_2' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats/history'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chat_history_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chat_history_request)); + } else { + $httpBody = $get_chat_history_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getChats_2 + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getChats_2($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_2'][0]) + { + list($response) = $this->getChats_2WithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getChats_2WithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetChatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getChats_2WithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_2'][0]) + { + $request = $this->getChats_2Request($business_id, $get_chats_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetChatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetChatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetChatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetChatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getChats_2Async + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChats_2Async($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_2'][0]) + { + return $this->getChats_2AsyncWithHttpInfo($business_id, $get_chats_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getChats_2AsyncWithHttpInfo + * + * Получение доступных чатов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getChats_2AsyncWithHttpInfo($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetChatsResponse'; + $request = $this->getChats_2Request($business_id, $get_chats_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getChats_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetChatsRequest $get_chats_request description (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getChats_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getChats_2Request($business_id, $get_chats_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getChats_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getChats_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getChats_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_chats_request' is set + if ($get_chats_request === null || (is_array($get_chats_request) && count($get_chats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_chats_request when calling getChats_2' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/chats'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_chats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_chats_request)); + } else { + $httpBody = $get_chats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedIndexLogs_3 + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedIndexLogs_3($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_3'][0]) + { + list($response) = $this->getFeedIndexLogs_3WithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + return $response; + } + + /** + * Operation getFeedIndexLogs_3WithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedIndexLogs_3WithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_3'][0]) + { + $request = $this->getFeedIndexLogs_3Request($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedIndexLogs_3Async + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogs_3Async($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_3'][0]) + { + return $this->getFeedIndexLogs_3AsyncWithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedIndexLogs_3AsyncWithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogs_3AsyncWithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + $request = $this->getFeedIndexLogs_3Request($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedIndexLogs_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedIndexLogs_3Request($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedIndexLogs_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getFeedIndexLogs_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeedIndexLogs_3' + ); + } + + + + + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/index-logs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_from, + 'published_time_from', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_to, + 'published_time_to', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'FeedIndexLogsStatusType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeed_3 + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeed_3($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_3'][0]) + { + list($response) = $this->getFeed_3WithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation getFeed_3WithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeed_3WithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_3'][0]) + { + $request = $this->getFeed_3Request($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeed_3Async + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeed_3Async($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_3'][0]) + { + return $this->getFeed_3AsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeed_3AsyncWithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeed_3AsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + $request = $this->getFeed_3Request($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeed_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeed_3Request($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeed_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getFeed_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeed_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedbackAndCommentUpdates_1 + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedbackAndCommentUpdates_1($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_1'][0]) + { + list($response) = $this->getFeedbackAndCommentUpdates_1WithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType); + return $response; + } + + /** + * Operation getFeedbackAndCommentUpdates_1WithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedbackAndCommentUpdates_1WithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_1'][0]) + { + $request = $this->getFeedbackAndCommentUpdates_1Request($campaign_id, $page_token, $limit, $from_date, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedbackListResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedbackListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedbackAndCommentUpdates_1Async + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdates_1Async($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_1'][0]) + { + return $this->getFeedbackAndCommentUpdates_1AsyncWithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedbackAndCommentUpdates_1AsyncWithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdates_1AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + $request = $this->getFeedbackAndCommentUpdates_1Request($campaign_id, $page_token, $limit, $from_date, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedbackAndCommentUpdates_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedbackAndCommentUpdates_1Request($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedbackAndCommentUpdates_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getFeedbackAndCommentUpdates_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/feedback/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeeds_3 + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeeds_3($campaign_id, string $contentType = self::contentTypes['getFeeds_3'][0]) + { + list($response) = $this->getFeeds_3WithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getFeeds_3WithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeeds_3WithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds_3'][0]) + { + $request = $this->getFeeds_3Request($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeeds_3Async + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeeds_3Async($campaign_id, string $contentType = self::contentTypes['getFeeds_3'][0]) + { + return $this->getFeeds_3AsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeeds_3AsyncWithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeeds_3AsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + $request = $this->getFeeds_3Request($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeeds_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeeds_3Request($campaign_id, string $contentType = self::contentTypes['getFeeds_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeeds_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getFeeds_3, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFulfillmentWarehouses_0 + * + * Идентификаторы складов Маркета (FBY) + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFulfillmentWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getFulfillmentWarehouses_0(string $contentType = self::contentTypes['getFulfillmentWarehouses_0'][0]) + { + list($response) = $this->getFulfillmentWarehouses_0WithHttpInfo($contentType); + return $response; + } + + /** + * Operation getFulfillmentWarehouses_0WithHttpInfo + * + * Идентификаторы складов Маркета (FBY) + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFulfillmentWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getFulfillmentWarehouses_0WithHttpInfo(string $contentType = self::contentTypes['getFulfillmentWarehouses_0'][0]) + { + $request = $this->getFulfillmentWarehouses_0Request($contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFulfillmentWarehouses_0Async + * + * Идентификаторы складов Маркета (FBY) + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getFulfillmentWarehouses_0Async(string $contentType = self::contentTypes['getFulfillmentWarehouses_0'][0]) + { + return $this->getFulfillmentWarehouses_0AsyncWithHttpInfo($contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFulfillmentWarehouses_0AsyncWithHttpInfo + * + * Идентификаторы складов Маркета (FBY) + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getFulfillmentWarehouses_0AsyncWithHttpInfo(string $contentType = self::contentTypes['getFulfillmentWarehouses_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse'; + $request = $this->getFulfillmentWarehouses_0Request($contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFulfillmentWarehouses_0' + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getFulfillmentWarehouses_0Request(string $contentType = self::contentTypes['getFulfillmentWarehouses_0'][0]) + { + + + $resourcePath = '/warehouses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbackComments_0 + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbackComments_0($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_0'][0]) + { + list($response) = $this->getGoodsFeedbackComments_0WithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbackComments_0WithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbackComments_0WithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_0'][0]) + { + $request = $this->getGoodsFeedbackComments_0Request($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbackComments_0Async + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackComments_0Async($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_0'][0]) + { + return $this->getGoodsFeedbackComments_0AsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbackComments_0AsyncWithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackComments_0AsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + $request = $this->getGoodsFeedbackComments_0Request($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbackComments_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbackComments_0Request($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbackComments_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getGoodsFeedbackComments_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_feedback_comments_request' is set + if ($get_goods_feedback_comments_request === null || (is_array($get_goods_feedback_comments_request) && count($get_goods_feedback_comments_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_feedback_comments_request when calling getGoodsFeedbackComments_0' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_comments_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_comments_request)); + } else { + $httpBody = $get_goods_feedback_comments_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbacks_0 + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbacks_0($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_0'][0]) + { + list($response) = $this->getGoodsFeedbacks_0WithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbacks_0WithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbacks_0WithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_0'][0]) + { + $request = $this->getGoodsFeedbacks_0Request($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbacks_0Async + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacks_0Async($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_0'][0]) + { + return $this->getGoodsFeedbacks_0AsyncWithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbacks_0AsyncWithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacks_0AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + $request = $this->getGoodsFeedbacks_0Request($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbacks_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbacks_0Request($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbacks_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getGoodsFeedbacks_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_request)); + } else { + $httpBody = $get_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsStats_0 + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsStats_0($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_0'][0]) + { + list($response) = $this->getGoodsStats_0WithHttpInfo($campaign_id, $get_goods_stats_request, $contentType); + return $response; + } + + /** + * Operation getGoodsStats_0WithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsStats_0WithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_0'][0]) + { + $request = $this->getGoodsStats_0Request($campaign_id, $get_goods_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsStats_0Async + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStats_0Async($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_0'][0]) + { + return $this->getGoodsStats_0AsyncWithHttpInfo($campaign_id, $get_goods_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsStats_0AsyncWithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStats_0AsyncWithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + $request = $this->getGoodsStats_0Request($campaign_id, $get_goods_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsStats_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsStats_0Request($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getGoodsStats_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getGoodsStats_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_stats_request' is set + if ($get_goods_stats_request === null || (is_array($get_goods_stats_request) && count($get_goods_stats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_stats_request when calling getGoodsStats_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/stats/skus'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_stats_request)); + } else { + $httpBody = $get_goods_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getHiddenOffers_0 + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getHiddenOffers_0($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_0'][0]) + { + list($response) = $this->getHiddenOffers_0WithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getHiddenOffers_0WithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getHiddenOffers_0WithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_0'][0]) + { + $request = $this->getHiddenOffers_0Request($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetHiddenOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetHiddenOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getHiddenOffers_0Async + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffers_0Async($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_0'][0]) + { + return $this->getHiddenOffers_0AsyncWithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getHiddenOffers_0AsyncWithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffers_0AsyncWithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + $request = $this->getHiddenOffers_0Request($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getHiddenOffers_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getHiddenOffers_0Request($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getHiddenOffers_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getHiddenOffers_0, must be bigger than or equal to 1.'); + } + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbyApi.getHiddenOffers_0, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offset, + 'offset', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferCardsContentStatus_1 + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferCardsContentStatus_1($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_1'][0]) + { + list($response) = $this->getOfferCardsContentStatus_1WithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + return $response; + } + + /** + * Operation getOfferCardsContentStatus_1WithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferCardsContentStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferCardsContentStatus_1WithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_1'][0]) + { + $request = $this->getOfferCardsContentStatus_1Request($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferCardsContentStatus_1Async + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatus_1Async($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_1'][0]) + { + return $this->getOfferCardsContentStatus_1AsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferCardsContentStatus_1AsyncWithHttpInfo + * + * Получение информации о заполненности карточек магазина + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferCardsContentStatus_1AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferCardsContentStatusResponse'; + $request = $this->getOfferCardsContentStatus_1Request($business_id, $page_token, $limit, $get_offer_cards_content_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferCardsContentStatus_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferCardsContentStatusRequest $get_offer_cards_content_status_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferCardsContentStatus_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferCardsContentStatus_1Request($business_id, $page_token = null, $limit = null, $get_offer_cards_content_status_request = null, string $contentType = self::contentTypes['getOfferCardsContentStatus_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferCardsContentStatus_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getOfferCardsContentStatus_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-cards'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_cards_content_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_cards_content_status_request)); + } else { + $httpBody = $get_offer_cards_content_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappingEntries_0 + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOfferMappingEntries_0($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_0'][0]) + { + list($response) = $this->getOfferMappingEntries_0WithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferMappingEntries_0WithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOfferMappingEntries_0WithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_0'][0]) + { + $request = $this->getOfferMappingEntries_0Request($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappingEntries_0Async + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntries_0Async($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_0'][0]) + { + return $this->getOfferMappingEntries_0AsyncWithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappingEntries_0AsyncWithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntries_0AsyncWithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + $request = $this->getOfferMappingEntries_0Request($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappingEntries_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOfferMappingEntries_0Request($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOfferMappingEntries_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getOfferMappingEntries_0, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_sku, + 'shop_sku', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $mapping_kind, + 'mapping_kind', // param base name + 'OfferMappingKindType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $availability, + 'availability', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $category_id, + 'category_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $vendor, + 'vendor', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferMappings_1 + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferMappings_1($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_1'][0]) + { + list($response) = $this->getOfferMappings_1WithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getOfferMappings_1WithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferMappings_1WithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_1'][0]) + { + $request = $this->getOfferMappings_1Request($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappings_1Async + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappings_1Async($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_1'][0]) + { + return $this->getOfferMappings_1AsyncWithHttpInfo($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappings_1AsyncWithHttpInfo + * + * Информация о товарах в каталоге + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferMappings_1AsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingsResponse'; + $request = $this->getOfferMappings_1Request($business_id, $page_token, $limit, $get_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappings_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOfferMappingsRequest $get_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferMappings_1Request($business_id, $page_token = null, $limit = null, $get_offer_mappings_request = null, string $contentType = self::contentTypes['getOfferMappings_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferMappings_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getOfferMappings_1, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/offer-mappings'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_mappings_request)); + } else { + $httpBody = $get_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferRecommendations_1 + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferRecommendations_1($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_1'][0]) + { + list($response) = $this->getOfferRecommendations_1WithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferRecommendations_1WithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferRecommendations_1WithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_1'][0]) + { + $request = $this->getOfferRecommendations_1Request($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferRecommendations_1Async + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendations_1Async($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_1'][0]) + { + return $this->getOfferRecommendations_1AsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferRecommendations_1AsyncWithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendations_1AsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + $request = $this->getOfferRecommendations_1Request($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferRecommendations_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferRecommendations_1Request($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferRecommendations_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getOfferRecommendations_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_offer_recommendations_request' is set + if ($get_offer_recommendations_request === null || (is_array($get_offer_recommendations_request) && count($get_offer_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_offer_recommendations_request when calling getOfferRecommendations_1' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/offers/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_recommendations_request)); + } else { + $httpBody = $get_offer_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOffers_3 + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOffers_3($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_3'][0]) + { + list($response) = $this->getOffers_3WithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getOffers_3WithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOffers_3WithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_3'][0]) + { + $request = $this->getOffers_3Request($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOffers_3Async + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffers_3Async($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_3'][0]) + { + return $this->getOffers_3AsyncWithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOffers_3AsyncWithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffers_3AsyncWithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + $request = $this->getOffers_3Request($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOffers_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOffers_3Request($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOffers_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getOffers_3, must be bigger than or equal to 1.'); + } + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbyApi.getOffers_3, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_category_id, + 'shopCategoryId', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $matched, + 'matched', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessBuyerInfo_1 + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessBuyerInfo_1($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_1'][0]) + { + list($response) = $this->getOrderBusinessBuyerInfo_1WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessBuyerInfo_1WithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessBuyerInfo_1WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_1'][0]) + { + $request = $this->getOrderBusinessBuyerInfo_1Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessBuyerInfo_1Async + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfo_1Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_1'][0]) + { + return $this->getOrderBusinessBuyerInfo_1AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessBuyerInfo_1AsyncWithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfo_1AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + $request = $this->getOrderBusinessBuyerInfo_1Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessBuyerInfo_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessBuyerInfo_1Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessBuyerInfo_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getOrderBusinessBuyerInfo_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessBuyerInfo_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/business-buyer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo_1 + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessDocumentsInfo_1($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_1'][0]) + { + list($response) = $this->getOrderBusinessDocumentsInfo_1WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessDocumentsInfo_1WithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessDocumentsInfo_1WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_1'][0]) + { + $request = $this->getOrderBusinessDocumentsInfo_1Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessDocumentsInfo_1Async + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfo_1Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_1'][0]) + { + return $this->getOrderBusinessDocumentsInfo_1AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo_1AsyncWithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfo_1AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + $request = $this->getOrderBusinessDocumentsInfo_1Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessDocumentsInfo_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessDocumentsInfo_1Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessDocumentsInfo_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getOrderBusinessDocumentsInfo_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessDocumentsInfo_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/documents'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrder_0 + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrder_0($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_0'][0]) + { + list($response) = $this->getOrder_0WithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrder_0WithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrder_0WithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_0'][0]) + { + $request = $this->getOrder_0Request($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrder_0Async + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrder_0Async($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_0'][0]) + { + return $this->getOrder_0AsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrder_0AsyncWithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrder_0AsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + $request = $this->getOrder_0Request($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrder_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrder_0Request($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrder_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getOrder_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrder_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrdersStats_0 + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrdersStats_0($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_0'][0]) + { + list($response) = $this->getOrdersStats_0WithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + return $response; + } + + /** + * Operation getOrdersStats_0WithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrdersStats_0WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_0'][0]) + { + $request = $this->getOrdersStats_0Request($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrdersStats_0Async + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStats_0Async($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_0'][0]) + { + return $this->getOrdersStats_0AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrdersStats_0AsyncWithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStats_0AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + $request = $this->getOrdersStats_0Request($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrdersStats_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrdersStats_0Request($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrdersStats_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getOrdersStats_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/stats/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_orders_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_orders_stats_request)); + } else { + $httpBody = $get_orders_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrders_2 + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrders_2($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_2'][0]) + { + list($response) = $this->getOrders_2WithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOrders_2WithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrders_2WithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_2'][0]) + { + $request = $this->getOrders_2Request($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrders_2Async + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrders_2Async($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_2'][0]) + { + return $this->getOrders_2AsyncWithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrders_2AsyncWithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrders_2AsyncWithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + $request = $this->getOrders_2Request($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrders_2' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrders_2Request($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders_2'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrders_2' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getOrders_2, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbyApi.getOrders_2, must be smaller than or equal to 10000.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $substatus, + 'substatus', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_from, + 'supplierShipmentDateFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_to, + 'supplierShipmentDateTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_from, + 'updatedAtFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_to, + 'updatedAtTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $dispatch_type, + 'dispatchType', // param base name + 'OrderDeliveryDispatchType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $fake, + 'fake', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $has_cis, + 'hasCis', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_waiting_for_cancellation_approve, + 'onlyWaitingForCancellationApprove', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_estimated_delivery, + 'onlyEstimatedDelivery', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_type, + 'buyerType', // param base name + 'OrderBuyerType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPricesByOfferIds_0 + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPricesByOfferIds_0($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_0'][0]) + { + list($response) = $this->getPricesByOfferIds_0WithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + return $response; + } + + /** + * Operation getPricesByOfferIds_0WithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPricesByOfferIds_0WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_0'][0]) + { + $request = $this->getPricesByOfferIds_0Request($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPricesByOfferIds_0Async + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIds_0Async($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_0'][0]) + { + return $this->getPricesByOfferIds_0AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPricesByOfferIds_0AsyncWithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIds_0AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + $request = $this->getPricesByOfferIds_0Request($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPricesByOfferIds_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPricesByOfferIds_0Request($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPricesByOfferIds_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getPricesByOfferIds_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_prices_by_offer_ids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_prices_by_offer_ids_request)); + } else { + $httpBody = $get_prices_by_offer_ids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPrices_0 + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getPrices_0($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_0'][0]) + { + list($response) = $this->getPrices_0WithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType); + return $response; + } + + /** + * Operation getPrices_0WithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getPrices_0WithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_0'][0]) + { + $request = $this->getPrices_0Request($campaign_id, $page_token, $limit, $archived, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPrices_0Async + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPrices_0Async($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_0'][0]) + { + return $this->getPrices_0AsyncWithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPrices_0AsyncWithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPrices_0AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + $request = $this->getPrices_0Request($campaign_id, $page_token, $limit, $archived, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPrices_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getPrices_0Request($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPrices_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getPrices_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromoOffers_0 + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromoOffers_0($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_0'][0]) + { + list($response) = $this->getPromoOffers_0WithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getPromoOffers_0WithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromoOffers_0WithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_0'][0]) + { + $request = $this->getPromoOffers_0Request($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromoOffers_0Async + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffers_0Async($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_0'][0]) + { + return $this->getPromoOffers_0AsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromoOffers_0AsyncWithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffers_0AsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + $request = $this->getPromoOffers_0Request($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromoOffers_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromoOffers_0Request($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromoOffers_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getPromoOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_promo_offers_request' is set + if ($get_promo_offers_request === null || (is_array($get_promo_offers_request) && count($get_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_promo_offers_request when calling getPromoOffers_0' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/promos/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promo_offers_request)); + } else { + $httpBody = $get_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromos_0 + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromos_0($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_0'][0]) + { + list($response) = $this->getPromos_0WithHttpInfo($business_id, $get_promos_request, $contentType); + return $response; + } + + /** + * Operation getPromos_0WithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromos_0WithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_0'][0]) + { + $request = $this->getPromos_0Request($business_id, $get_promos_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromosResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromosResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromosResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromosResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromos_0Async + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromos_0Async($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_0'][0]) + { + return $this->getPromos_0AsyncWithHttpInfo($business_id, $get_promos_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromos_0AsyncWithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromos_0AsyncWithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + $request = $this->getPromos_0Request($business_id, $get_promos_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromos_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromos_0Request($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromos_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getPromos_0, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/promos'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promos_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promos_request)); + } else { + $httpBody = $get_promos_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getQualityRatings_0 + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatings_0($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_0'][0]) + { + list($response) = $this->getQualityRatings_0WithHttpInfo($business_id, $get_quality_rating_request, $contentType); + return $response; + } + + /** + * Operation getQualityRatings_0WithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatings_0WithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_0'][0]) + { + $request = $this->getQualityRatings_0Request($business_id, $get_quality_rating_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatings_0Async + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatings_0Async($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_0'][0]) + { + return $this->getQualityRatings_0AsyncWithHttpInfo($business_id, $get_quality_rating_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatings_0AsyncWithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatings_0AsyncWithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + $request = $this->getQualityRatings_0Request($business_id, $get_quality_rating_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatings_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatings_0Request($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getQualityRatings_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getQualityRatings_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quality_rating_request' is set + if ($get_quality_rating_request === null || (is_array($get_quality_rating_request) && count($get_quality_rating_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quality_rating_request when calling getQualityRatings_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/ratings/quality'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quality_rating_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quality_rating_request)); + } else { + $httpBody = $get_quality_rating_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReportInfo_0 + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReportInfo_0($report_id, string $contentType = self::contentTypes['getReportInfo_0'][0]) + { + list($response) = $this->getReportInfo_0WithHttpInfo($report_id, $contentType); + return $response; + } + + /** + * Operation getReportInfo_0WithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReportInfo_0WithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo_0'][0]) + { + $request = $this->getReportInfo_0Request($report_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReportInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReportInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReportInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReportInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReportInfo_0Async + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfo_0Async($report_id, string $contentType = self::contentTypes['getReportInfo_0'][0]) + { + return $this->getReportInfo_0AsyncWithHttpInfo($report_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReportInfo_0AsyncWithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfo_0AsyncWithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + $request = $this->getReportInfo_0Request($report_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReportInfo_0' + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReportInfo_0Request($report_id, string $contentType = self::contentTypes['getReportInfo_0'][0]) + { + + // verify the required parameter 'report_id' is set + if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $report_id when calling getReportInfo_0' + ); + } + + + $resourcePath = '/reports/info/{reportId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($report_id !== null) { + $resourcePath = str_replace( + '{' . 'reportId' . '}', + ObjectSerializer::toPathValue($report_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnPhoto_3 + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnPhoto_3($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_3'][0]) + { + list($response) = $this->getReturnPhoto_3WithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + return $response; + } + + /** + * Operation getReturnPhoto_3WithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnPhoto_3WithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_3'][0]) + { + $request = $this->getReturnPhoto_3Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnPhoto_3Async + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhoto_3Async($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_3'][0]) + { + return $this->getReturnPhoto_3AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnPhoto_3AsyncWithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhoto_3AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_3'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnPhoto_3Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnPhoto_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnPhoto_3Request($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnPhoto_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getReturnPhoto_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnPhoto_3' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnPhoto_3' + ); + } + + // verify the required parameter 'item_id' is set + if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $item_id when calling getReturnPhoto_3' + ); + } + + // verify the required parameter 'image_hash' is set + if ($image_hash === null || (is_array($image_hash) && count($image_hash) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $image_hash when calling getReturnPhoto_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision/{itemId}/image/{imageHash}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + // path params + if ($item_id !== null) { + $resourcePath = str_replace( + '{' . 'itemId' . '}', + ObjectSerializer::toPathValue($item_id), + $resourcePath + ); + } + // path params + if ($image_hash !== null) { + $resourcePath = str_replace( + '{' . 'imageHash' . '}', + ObjectSerializer::toPathValue($image_hash), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturn_3 + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturn_3($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_3'][0]) + { + list($response) = $this->getReturn_3WithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturn_3WithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturn_3WithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_3'][0]) + { + $request = $this->getReturn_3Request($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturn_3Async + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturn_3Async($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_3'][0]) + { + return $this->getReturn_3AsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturn_3AsyncWithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturn_3AsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + $request = $this->getReturn_3Request($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturn_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturn_3Request($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturn_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getReturn_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturn_3' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturn_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturns_3 + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturns_3($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_3'][0]) + { + list($response) = $this->getReturns_3WithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + return $response; + } + + /** + * Operation getReturns_3WithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturns_3WithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_3'][0]) + { + $request = $this->getReturns_3Request($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturns_3Async + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturns_3Async($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_3'][0]) + { + return $this->getReturns_3AsyncWithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturns_3AsyncWithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturns_3AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + $request = $this->getReturns_3Request($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturns_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturns_3Request($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturns_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getReturns_3, must be bigger than or equal to 1.'); + } + + + + if ($order_ids !== null && count($order_ids) > 50) { + throw new \InvalidArgumentException('invalid value for "$order_ids" when calling FbyApi.getReturns_3, number of items must be less than or equal to 50.'); + } + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/returns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $statuses, + 'statuses', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $type, + 'type', // param base name + 'ReturnType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date2, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date2, + 'to_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getStocks_0 + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getStocks_0($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_0'][0]) + { + list($response) = $this->getStocks_0WithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + return $response; + } + + /** + * Operation getStocks_0WithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getStocks_0WithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_0'][0]) + { + $request = $this->getStocks_0Request($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehouseStocksResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehouseStocksResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getStocks_0Async + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocks_0Async($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_0'][0]) + { + return $this->getStocks_0AsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getStocks_0AsyncWithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocks_0AsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + $request = $this->getStocks_0Request($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getStocks_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getStocks_0Request($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getStocks_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getStocks_0, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_warehouse_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_warehouse_stocks_request)); + } else { + $httpBody = $get_warehouse_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappingEntries_0 + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedOfferMappingEntries_0($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_0'][0]) + { + list($response) = $this->getSuggestedOfferMappingEntries_0WithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappingEntries_0WithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedOfferMappingEntries_0WithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_0'][0]) + { + $request = $this->getSuggestedOfferMappingEntries_0Request($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappingEntries_0Async + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntries_0Async($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_0'][0]) + { + return $this->getSuggestedOfferMappingEntries_0AsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappingEntries_0AsyncWithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntries_0AsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + $request = $this->getSuggestedOfferMappingEntries_0Request($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappingEntries_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedOfferMappingEntries_0Request($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedOfferMappingEntries_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getSuggestedOfferMappingEntries_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_suggested_offer_mapping_entries_request' is set + if ($get_suggested_offer_mapping_entries_request === null || (is_array($get_suggested_offer_mapping_entries_request) && count($get_suggested_offer_mapping_entries_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_suggested_offer_mapping_entries_request when calling getSuggestedOfferMappingEntries_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mapping_entries_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mapping_entries_request)); + } else { + $httpBody = $get_suggested_offer_mapping_entries_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappings_1 + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getSuggestedOfferMappings_1($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_1'][0]) + { + list($response) = $this->getSuggestedOfferMappings_1WithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappings_1WithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getSuggestedOfferMappings_1WithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_1'][0]) + { + $request = $this->getSuggestedOfferMappings_1Request($business_id, $get_suggested_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappings_1Async + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappings_1Async($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_1'][0]) + { + return $this->getSuggestedOfferMappings_1AsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappings_1AsyncWithHttpInfo + * + * Просмотр карточек на Маркете, которые подходят вашим товарам + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getSuggestedOfferMappings_1AsyncWithHttpInfo($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResponse'; + $request = $this->getSuggestedOfferMappings_1Request($business_id, $get_suggested_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappings_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsRequest $get_suggested_offer_mappings_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getSuggestedOfferMappings_1Request($business_id, $get_suggested_offer_mappings_request = null, string $contentType = self::contentTypes['getSuggestedOfferMappings_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getSuggestedOfferMappings_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.getSuggestedOfferMappings_1, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/offer-mappings/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mappings_request)); + } else { + $httpBody = $get_suggested_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedPrices_0 + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedPrices_0($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_0'][0]) + { + list($response) = $this->getSuggestedPrices_0WithHttpInfo($campaign_id, $suggest_prices_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedPrices_0WithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedPrices_0WithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_0'][0]) + { + $request = $this->getSuggestedPrices_0Request($campaign_id, $suggest_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SuggestPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SuggestPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SuggestPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SuggestPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedPrices_0Async + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPrices_0Async($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_0'][0]) + { + return $this->getSuggestedPrices_0AsyncWithHttpInfo($campaign_id, $suggest_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedPrices_0AsyncWithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPrices_0AsyncWithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + $request = $this->getSuggestedPrices_0Request($campaign_id, $suggest_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedPrices_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedPrices_0Request($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedPrices_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.getSuggestedPrices_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'suggest_prices_request' is set + if ($suggest_prices_request === null || (is_array($suggest_prices_request) && count($suggest_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $suggest_prices_request when calling getSuggestedPrices_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($suggest_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($suggest_prices_request)); + } else { + $httpBody = $suggest_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForBusiness_2 + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForBusiness_2($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_2'][0]) + { + list($response) = $this->putBidsForBusiness_2WithHttpInfo($business_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForBusiness_2WithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForBusiness_2WithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_2'][0]) + { + $request = $this->putBidsForBusiness_2Request($business_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForBusiness_2Async + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusiness_2Async($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_2'][0]) + { + return $this->putBidsForBusiness_2AsyncWithHttpInfo($business_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForBusiness_2AsyncWithHttpInfo + * + * Включение буста продаж и установка ставок + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForBusiness_2AsyncWithHttpInfo($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForBusiness_2Request($business_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForBusiness_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForBusiness_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForBusiness_2Request($business_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForBusiness_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling putBidsForBusiness_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.putBidsForBusiness_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForBusiness_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation putBidsForCampaign_3 + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function putBidsForCampaign_3($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_3'][0]) + { + list($response) = $this->putBidsForCampaign_3WithHttpInfo($campaign_id, $put_sku_bids_request, $contentType); + return $response; + } + + /** + * Operation putBidsForCampaign_3WithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function putBidsForCampaign_3WithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_3'][0]) + { + $request = $this->putBidsForCampaign_3Request($campaign_id, $put_sku_bids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation putBidsForCampaign_3Async + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaign_3Async($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_3'][0]) + { + return $this->putBidsForCampaign_3AsyncWithHttpInfo($campaign_id, $put_sku_bids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation putBidsForCampaign_3AsyncWithHttpInfo + * + * Включение буста продаж и установка ставок для магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function putBidsForCampaign_3AsyncWithHttpInfo($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->putBidsForCampaign_3Request($campaign_id, $put_sku_bids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'putBidsForCampaign_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\PutSkuBidsRequest $put_sku_bids_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['putBidsForCampaign_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function putBidsForCampaign_3Request($campaign_id, $put_sku_bids_request, string $contentType = self::contentTypes['putBidsForCampaign_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling putBidsForCampaign_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.putBidsForCampaign_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'put_sku_bids_request' is set + if ($put_sku_bids_request === null || (is_array($put_sku_bids_request) && count($put_sku_bids_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $put_sku_bids_request when calling putBidsForCampaign_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/bids'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($put_sku_bids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($put_sku_bids_request)); + } else { + $httpBody = $put_sku_bids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation refreshFeed_3 + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function refreshFeed_3($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_3'][0]) + { + list($response) = $this->refreshFeed_3WithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation refreshFeed_3WithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function refreshFeed_3WithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_3'][0]) + { + $request = $this->refreshFeed_3Request($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation refreshFeed_3Async + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeed_3Async($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_3'][0]) + { + return $this->refreshFeed_3AsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation refreshFeed_3AsyncWithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeed_3AsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->refreshFeed_3Request($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'refreshFeed_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function refreshFeed_3Request($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling refreshFeed_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.refreshFeed_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling refreshFeed_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/refresh'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionChildren_0 + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionChildren_0($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_0'][0]) + { + list($response) = $this->searchRegionChildren_0WithHttpInfo($region_id, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation searchRegionChildren_0WithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionChildren_0WithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_0'][0]) + { + $request = $this->searchRegionChildren_0Request($region_id, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionChildren_0Async + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildren_0Async($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_0'][0]) + { + return $this->searchRegionChildren_0AsyncWithHttpInfo($region_id, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionChildren_0AsyncWithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildren_0AsyncWithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + $request = $this->searchRegionChildren_0Request($region_id, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionChildren_0' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionChildren_0Request($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren_0'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionChildren_0' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling FbyApi.searchRegionChildren_0, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/regions/{regionId}/children'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsById_0 + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsById_0($region_id, string $contentType = self::contentTypes['searchRegionsById_0'][0]) + { + list($response) = $this->searchRegionsById_0WithHttpInfo($region_id, $contentType); + return $response; + } + + /** + * Operation searchRegionsById_0WithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsById_0WithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById_0'][0]) + { + $request = $this->searchRegionsById_0Request($region_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsById_0Async + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsById_0Async($region_id, string $contentType = self::contentTypes['searchRegionsById_0'][0]) + { + return $this->searchRegionsById_0AsyncWithHttpInfo($region_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsById_0AsyncWithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsById_0AsyncWithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsById_0Request($region_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsById_0' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsById_0Request($region_id, string $contentType = self::contentTypes['searchRegionsById_0'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionsById_0' + ); + } + + + $resourcePath = '/regions/{regionId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsByName_0 + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsByName_0($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_0'][0]) + { + list($response) = $this->searchRegionsByName_0WithHttpInfo($name, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation searchRegionsByName_0WithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsByName_0WithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_0'][0]) + { + $request = $this->searchRegionsByName_0Request($name, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsByName_0Async + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByName_0Async($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_0'][0]) + { + return $this->searchRegionsByName_0AsyncWithHttpInfo($name, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsByName_0AsyncWithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByName_0AsyncWithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsByName_0Request($name, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsByName_0' + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsByName_0Request($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName_0'][0]) + { + + // verify the required parameter 'name' is set + if ($name === null || (is_array($name) && count($name) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $name when calling searchRegionsByName_0' + ); + } + + + + + $resourcePath = '/regions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $name, + 'name', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendFileToChat_2 + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendFileToChat_2($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_2'][0]) + { + list($response) = $this->sendFileToChat_2WithHttpInfo($business_id, $chat_id, $file, $contentType); + return $response; + } + + /** + * Operation sendFileToChat_2WithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendFileToChat_2WithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_2'][0]) + { + $request = $this->sendFileToChat_2Request($business_id, $chat_id, $file, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendFileToChat_2Async + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChat_2Async($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_2'][0]) + { + return $this->sendFileToChat_2AsyncWithHttpInfo($business_id, $chat_id, $file, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendFileToChat_2AsyncWithHttpInfo + * + * Отправка файла в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendFileToChat_2AsyncWithHttpInfo($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendFileToChat_2Request($business_id, $chat_id, $file, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendFileToChat_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \SplFileObject $file Содержимое файла. Максимальный размер файла — 5 Мбайт. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendFileToChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendFileToChat_2Request($business_id, $chat_id, $file, string $contentType = self::contentTypes['sendFileToChat_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendFileToChat_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.sendFileToChat_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendFileToChat_2' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling FbyApi.sendFileToChat_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'file' is set + if ($file === null || (is_array($file) && count($file) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $file when calling sendFileToChat_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/file/send'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + // form params + if ($file !== null) { + $multipart = true; + $formParams['file'] = []; + $paramFiles = is_array($file) ? $file : [$file]; + foreach ($paramFiles as $paramFile) { + $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( + ObjectSerializer::toFormValue($paramFile), + 'rb' + ); + } + } + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation sendMessageToChat_2 + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function sendMessageToChat_2($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_2'][0]) + { + list($response) = $this->sendMessageToChat_2WithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType); + return $response; + } + + /** + * Operation sendMessageToChat_2WithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_2'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function sendMessageToChat_2WithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_2'][0]) + { + $request = $this->sendMessageToChat_2Request($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation sendMessageToChat_2Async + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChat_2Async($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_2'][0]) + { + return $this->sendMessageToChat_2AsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation sendMessageToChat_2AsyncWithHttpInfo + * + * Отправка сообщения в чат + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function sendMessageToChat_2AsyncWithHttpInfo($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_2'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->sendMessageToChat_2Request($business_id, $chat_id, $send_message_to_chat_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'sendMessageToChat_2' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $chat_id Идентификатор чата. (required) + * @param \OpenAPI\Client\Model\SendMessageToChatRequest $send_message_to_chat_request description (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['sendMessageToChat_2'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function sendMessageToChat_2Request($business_id, $chat_id, $send_message_to_chat_request, string $contentType = self::contentTypes['sendMessageToChat_2'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling sendMessageToChat_2' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.sendMessageToChat_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'chat_id' is set + if ($chat_id === null || (is_array($chat_id) && count($chat_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $chat_id when calling sendMessageToChat_2' + ); + } + if ($chat_id < 1) { + throw new \InvalidArgumentException('invalid value for "$chat_id" when calling FbyApi.sendMessageToChat_2, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'send_message_to_chat_request' is set + if ($send_message_to_chat_request === null || (is_array($send_message_to_chat_request) && count($send_message_to_chat_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $send_message_to_chat_request when calling sendMessageToChat_2' + ); + } + + + $resourcePath = '/businesses/{businessId}/chats/message'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chat_id, + 'chatId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($send_message_to_chat_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($send_message_to_chat_request)); + } else { + $httpBody = $send_message_to_chat_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setFeedParams_3 + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function setFeedParams_3($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_3'][0]) + { + list($response) = $this->setFeedParams_3WithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType); + return $response; + } + + /** + * Operation setFeedParams_3WithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_3'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function setFeedParams_3WithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_3'][0]) + { + $request = $this->setFeedParams_3Request($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setFeedParams_3Async + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParams_3Async($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_3'][0]) + { + return $this->setFeedParams_3AsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setFeedParams_3AsyncWithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParams_3AsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_3'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setFeedParams_3Request($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setFeedParams_3' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams_3'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function setFeedParams_3Request($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams_3'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setFeedParams_3' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.setFeedParams_3, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling setFeedParams_3' + ); + } + + // verify the required parameter 'set_feed_params_request' is set + if ($set_feed_params_request === null || (is_array($set_feed_params_request) && count($set_feed_params_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_feed_params_request when calling setFeedParams_3' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/params'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_feed_params_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_feed_params_request)); + } else { + $httpBody = $set_feed_params_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation skipGoodsFeedbacksReaction_0 + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function skipGoodsFeedbacksReaction_0($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_0'][0]) + { + list($response) = $this->skipGoodsFeedbacksReaction_0WithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType); + return $response; + } + + /** + * Operation skipGoodsFeedbacksReaction_0WithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function skipGoodsFeedbacksReaction_0WithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_0'][0]) + { + $request = $this->skipGoodsFeedbacksReaction_0Request($business_id, $skip_goods_feedback_reaction_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation skipGoodsFeedbacksReaction_0Async + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReaction_0Async($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_0'][0]) + { + return $this->skipGoodsFeedbacksReaction_0AsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation skipGoodsFeedbacksReaction_0AsyncWithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReaction_0AsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->skipGoodsFeedbacksReaction_0Request($business_id, $skip_goods_feedback_reaction_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'skipGoodsFeedbacksReaction_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function skipGoodsFeedbacksReaction_0Request($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling skipGoodsFeedbacksReaction_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.skipGoodsFeedbacksReaction_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'skip_goods_feedback_reaction_request' is set + if ($skip_goods_feedback_reaction_request === null || (is_array($skip_goods_feedback_reaction_request) && count($skip_goods_feedback_reaction_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $skip_goods_feedback_reaction_request when calling skipGoodsFeedbacksReaction_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/skip-reaction'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($skip_goods_feedback_reaction_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($skip_goods_feedback_reaction_request)); + } else { + $httpBody = $skip_goods_feedback_reaction_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateBusinessPrices_0 + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateBusinessPrices_0($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_0'][0]) + { + list($response) = $this->updateBusinessPrices_0WithHttpInfo($business_id, $update_business_prices_request, $contentType); + return $response; + } + + /** + * Operation updateBusinessPrices_0WithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateBusinessPrices_0WithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_0'][0]) + { + $request = $this->updateBusinessPrices_0Request($business_id, $update_business_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateBusinessPrices_0Async + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPrices_0Async($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_0'][0]) + { + return $this->updateBusinessPrices_0AsyncWithHttpInfo($business_id, $update_business_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateBusinessPrices_0AsyncWithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPrices_0AsyncWithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateBusinessPrices_0Request($business_id, $update_business_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateBusinessPrices_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateBusinessPrices_0Request($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateBusinessPrices_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.updateBusinessPrices_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_business_prices_request' is set + if ($update_business_prices_request === null || (is_array($update_business_prices_request) && count($update_business_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_business_prices_request when calling updateBusinessPrices_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_business_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_business_prices_request)); + } else { + $httpBody = $update_business_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateCampaignOffers_1 + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateCampaignOffers_1($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_1'][0]) + { + list($response) = $this->updateCampaignOffers_1WithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation updateCampaignOffers_1WithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateCampaignOffers_1WithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_1'][0]) + { + $request = $this->updateCampaignOffers_1Request($campaign_id, $update_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateCampaignOffers_1Async + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffers_1Async($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_1'][0]) + { + return $this->updateCampaignOffers_1AsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateCampaignOffers_1AsyncWithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffers_1AsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateCampaignOffers_1Request($campaign_id, $update_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateCampaignOffers_1' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateCampaignOffers_1Request($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers_1'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateCampaignOffers_1' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.updateCampaignOffers_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_campaign_offers_request' is set + if ($update_campaign_offers_request === null || (is_array($update_campaign_offers_request) && count($update_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_campaign_offers_request when calling updateCampaignOffers_1' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_campaign_offers_request)); + } else { + $httpBody = $update_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateGoodsFeedbackComment_0 + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateGoodsFeedbackComment_0($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_0'][0]) + { + list($response) = $this->updateGoodsFeedbackComment_0WithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation updateGoodsFeedbackComment_0WithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateGoodsFeedbackComment_0WithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_0'][0]) + { + $request = $this->updateGoodsFeedbackComment_0Request($business_id, $update_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateGoodsFeedbackComment_0Async + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackComment_0Async($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_0'][0]) + { + return $this->updateGoodsFeedbackComment_0AsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateGoodsFeedbackComment_0AsyncWithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackComment_0AsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + $request = $this->updateGoodsFeedbackComment_0Request($business_id, $update_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateGoodsFeedbackComment_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateGoodsFeedbackComment_0Request($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateGoodsFeedbackComment_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.updateGoodsFeedbackComment_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_goods_feedback_comment_request' is set + if ($update_goods_feedback_comment_request === null || (is_array($update_goods_feedback_comment_request) && count($update_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_goods_feedback_comment_request when calling updateGoodsFeedbackComment_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_goods_feedback_comment_request)); + } else { + $httpBody = $update_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferContent_1 + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferContent_1($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_1'][0]) + { + list($response) = $this->updateOfferContent_1WithHttpInfo($business_id, $update_offer_content_request, $contentType); + return $response; + } + + /** + * Operation updateOfferContent_1WithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferContentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferContent_1WithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_1'][0]) + { + $request = $this->updateOfferContent_1Request($business_id, $update_offer_content_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferContentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferContentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferContentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferContent_1Async + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContent_1Async($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_1'][0]) + { + return $this->updateOfferContent_1AsyncWithHttpInfo($business_id, $update_offer_content_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferContent_1AsyncWithHttpInfo + * + * Редактирование категорийных характеристик товара + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferContent_1AsyncWithHttpInfo($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferContentResponse'; + $request = $this->updateOfferContent_1Request($business_id, $update_offer_content_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferContent_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferContentRequest $update_offer_content_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferContent_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferContent_1Request($business_id, $update_offer_content_request, string $contentType = self::contentTypes['updateOfferContent_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferContent_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.updateOfferContent_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_content_request' is set + if ($update_offer_content_request === null || (is_array($update_offer_content_request) && count($update_offer_content_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_content_request when calling updateOfferContent_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-cards/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_content_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_content_request)); + } else { + $httpBody = $update_offer_content_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappingEntries_0 + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function updateOfferMappingEntries_0($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_0'][0]) + { + list($response) = $this->updateOfferMappingEntries_0WithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappingEntries_0WithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function updateOfferMappingEntries_0WithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_0'][0]) + { + $request = $this->updateOfferMappingEntries_0Request($campaign_id, $update_offer_mapping_entry_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappingEntries_0Async + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntries_0Async($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_0'][0]) + { + return $this->updateOfferMappingEntries_0AsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappingEntries_0AsyncWithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntries_0AsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOfferMappingEntries_0Request($campaign_id, $update_offer_mapping_entry_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappingEntries_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function updateOfferMappingEntries_0Request($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOfferMappingEntries_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.updateOfferMappingEntries_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mapping_entry_request' is set + if ($update_offer_mapping_entry_request === null || (is_array($update_offer_mapping_entry_request) && count($update_offer_mapping_entry_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mapping_entry_request when calling updateOfferMappingEntries_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mapping_entry_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mapping_entry_request)); + } else { + $httpBody = $update_offer_mapping_entry_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappings_1 + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOfferMappings_1($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_1'][0]) + { + list($response) = $this->updateOfferMappings_1WithHttpInfo($business_id, $update_offer_mappings_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappings_1WithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_1'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOfferMappingsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOfferMappings_1WithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_1'][0]) + { + $request = $this->updateOfferMappings_1Request($business_id, $update_offer_mappings_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOfferMappingsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOfferMappingsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappings_1Async + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappings_1Async($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_1'][0]) + { + return $this->updateOfferMappings_1AsyncWithHttpInfo($business_id, $update_offer_mappings_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappings_1AsyncWithHttpInfo + * + * Добавление товаров в каталог и изменение информации о них + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOfferMappings_1AsyncWithHttpInfo($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_1'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOfferMappingsResponse'; + $request = $this->updateOfferMappings_1Request($business_id, $update_offer_mappings_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappings_1' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingsRequest $update_offer_mappings_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappings_1'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOfferMappings_1Request($business_id, $update_offer_mappings_request, string $contentType = self::contentTypes['updateOfferMappings_1'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateOfferMappings_1' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.updateOfferMappings_1, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mappings_request' is set + if ($update_offer_mappings_request === null || (is_array($update_offer_mappings_request) && count($update_offer_mappings_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mappings_request when calling updateOfferMappings_1' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-mappings/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mappings_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mappings_request)); + } else { + $httpBody = $update_offer_mappings_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePrices_0 + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePrices_0($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_0'][0]) + { + list($response) = $this->updatePrices_0WithHttpInfo($campaign_id, $update_prices_request, $contentType); + return $response; + } + + /** + * Operation updatePrices_0WithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePrices_0WithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_0'][0]) + { + $request = $this->updatePrices_0Request($campaign_id, $update_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePrices_0Async + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePrices_0Async($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_0'][0]) + { + return $this->updatePrices_0AsyncWithHttpInfo($campaign_id, $update_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePrices_0AsyncWithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePrices_0AsyncWithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updatePrices_0Request($campaign_id, $update_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePrices_0' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePrices_0Request($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices_0'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updatePrices_0' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FbyApi.updatePrices_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_prices_request' is set + if ($update_prices_request === null || (is_array($update_prices_request) && count($update_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_prices_request when calling updatePrices_0' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_prices_request)); + } else { + $httpBody = $update_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePromoOffers_0 + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePromoOffers_0($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_0'][0]) + { + list($response) = $this->updatePromoOffers_0WithHttpInfo($business_id, $update_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation updatePromoOffers_0WithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_0'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePromoOffers_0WithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_0'][0]) + { + $request = $this->updatePromoOffers_0Request($business_id, $update_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdatePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdatePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePromoOffers_0Async + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffers_0Async($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_0'][0]) + { + return $this->updatePromoOffers_0AsyncWithHttpInfo($business_id, $update_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePromoOffers_0AsyncWithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffers_0AsyncWithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_0'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + $request = $this->updatePromoOffers_0Request($business_id, $update_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePromoOffers_0' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers_0'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePromoOffers_0Request($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers_0'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updatePromoOffers_0' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling FbyApi.updatePromoOffers_0, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_promo_offers_request' is set + if ($update_promo_offers_request === null || (is_array($update_promo_offers_request) && count($update_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_promo_offers_request when calling updatePromoOffers_0' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_promo_offers_request)); + } else { + $httpBody = $update_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/FeedbacksApi.php b/erp24/lib/yandex_market_api/Api/FeedbacksApi.php new file mode 100644 index 00000000..6c4b6f0b --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/FeedbacksApi.php @@ -0,0 +1,723 @@ + [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getFeedbackAndCommentUpdates + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedbackAndCommentUpdates($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates'][0]) + { + list($response) = $this->getFeedbackAndCommentUpdatesWithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType); + return $response; + } + + /** + * Operation getFeedbackAndCommentUpdatesWithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedbackListResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedbackAndCommentUpdatesWithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates'][0]) + { + $request = $this->getFeedbackAndCommentUpdatesRequest($campaign_id, $page_token, $limit, $from_date, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedbackListResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedbackListResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedbackListResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedbackAndCommentUpdatesAsync + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdatesAsync($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates'][0]) + { + return $this->getFeedbackAndCommentUpdatesAsyncWithHttpInfo($campaign_id, $page_token, $limit, $from_date, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedbackAndCommentUpdatesAsyncWithHttpInfo + * + * Новые и обновленные отзывы о магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedbackAndCommentUpdatesAsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedbackListResponse'; + $request = $this->getFeedbackAndCommentUpdatesRequest($campaign_id, $page_token, $limit, $from_date, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedbackAndCommentUpdates' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $from_date Начальная дата обновления отзывов. Если параметр указан, возвращаются отзывы, которые были написаны или обновлены с этой даты. Формат даты: `ГГГГ-ММ-ДД`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedbackAndCommentUpdates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedbackAndCommentUpdatesRequest($campaign_id, $page_token = null, $limit = null, $from_date = null, string $contentType = self::contentTypes['getFeedbackAndCommentUpdates'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedbackAndCommentUpdates' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FeedbacksApi.getFeedbackAndCommentUpdates, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/feedback/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/FeedsApi.php b/erp24/lib/yandex_market_api/Api/FeedsApi.php new file mode 100644 index 00000000..24930e1f --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/FeedsApi.php @@ -0,0 +1,3024 @@ + [ + 'application/json', + ], + 'getFeedIndexLogs' => [ + 'application/json', + ], + 'getFeeds' => [ + 'application/json', + ], + 'refreshFeed' => [ + 'application/json', + ], + 'setFeedParams' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getFeed + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeed($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed'][0]) + { + list($response) = $this->getFeedWithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation getFeedWithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed'][0]) + { + $request = $this->getFeedRequest($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedAsync + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedAsync($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed'][0]) + { + return $this->getFeedAsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedAsyncWithHttpInfo + * + * Информация о прайс-листе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedAsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedResponse'; + $request = $this->getFeedRequest($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeed' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeed'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedRequest($campaign_id, $feed_id, string $contentType = self::contentTypes['getFeed'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeed' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FeedsApi.getFeed, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeed' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeedIndexLogs + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeedIndexLogs($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs'][0]) + { + list($response) = $this->getFeedIndexLogsWithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + return $response; + } + + /** + * Operation getFeedIndexLogsWithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedIndexLogsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedIndexLogsWithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs'][0]) + { + $request = $this->getFeedIndexLogsRequest($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedIndexLogsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedIndexLogsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedIndexLogsAsync + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogsAsync($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs'][0]) + { + return $this->getFeedIndexLogsAsyncWithHttpInfo($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedIndexLogsAsyncWithHttpInfo + * + * Отчет по индексации прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedIndexLogsAsyncWithHttpInfo($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedIndexLogsResponse'; + $request = $this->getFeedIndexLogsRequest($campaign_id, $feed_id, $limit, $published_time_from, $published_time_to, $status, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeedIndexLogs' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param int $limit Количество значений на одной странице. (optional) + * @param \DateTime $published_time_from Начальная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Значение по умолчанию: последние восемь дней со времени отправки запроса. (optional) + * @param \DateTime $published_time_to Конечная дата. Используется для фильтрации записей — по дате и времени публикации предложений на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-31T00:42:42+03:00`. Значение по умолчанию: дата и время отправки запроса. {% note info %} Если во время переключения между страницами выходных данных на Яндекс Маркете появятся новые результаты индексации прайс-листа, вы не получите часть данных. Чтобы этого не произошло, зафиксируйте выходные данные с помощью входного параметра `published_time_to`. Значение параметра не должно быть датой из будущего. {% endnote %} (optional) + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType $status Статус индексации и проверки прайс-листа на соответствие техническим требованиям. Возможные значения: * `ERROR` — произошли ошибки. * `OK` — обработан без ошибок. * `WARNING` — наблюдались некритичные проблемы. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeedIndexLogs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedIndexLogsRequest($campaign_id, $feed_id, $limit = null, $published_time_from = null, $published_time_to = null, $status = null, string $contentType = self::contentTypes['getFeedIndexLogs'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeedIndexLogs' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FeedsApi.getFeedIndexLogs, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling getFeedIndexLogs' + ); + } + + + + + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/index-logs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_from, + 'published_time_from', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $published_time_to, + 'published_time_to', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'FeedIndexLogsStatusType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getFeeds + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getFeeds($campaign_id, string $contentType = self::contentTypes['getFeeds'][0]) + { + list($response) = $this->getFeedsWithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getFeedsWithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFeedsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getFeedsWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds'][0]) + { + $request = $this->getFeedsRequest($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFeedsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFeedsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFeedsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFeedsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFeedsAsync + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedsAsync($campaign_id, string $contentType = self::contentTypes['getFeeds'][0]) + { + return $this->getFeedsAsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFeedsAsyncWithHttpInfo + * + * Список прайс-листов магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getFeedsAsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getFeeds'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFeedsResponse'; + $request = $this->getFeedsRequest($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFeeds' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFeeds'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getFeedsRequest($campaign_id, string $contentType = self::contentTypes['getFeeds'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getFeeds' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FeedsApi.getFeeds, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation refreshFeed + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function refreshFeed($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed'][0]) + { + list($response) = $this->refreshFeedWithHttpInfo($campaign_id, $feed_id, $contentType); + return $response; + } + + /** + * Operation refreshFeedWithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function refreshFeedWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed'][0]) + { + $request = $this->refreshFeedRequest($campaign_id, $feed_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation refreshFeedAsync + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeedAsync($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed'][0]) + { + return $this->refreshFeedAsyncWithHttpInfo($campaign_id, $feed_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation refreshFeedAsyncWithHttpInfo + * + * Сообщить, что прайс-лист обновился + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function refreshFeedAsyncWithHttpInfo($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->refreshFeedRequest($campaign_id, $feed_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'refreshFeed' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['refreshFeed'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function refreshFeedRequest($campaign_id, $feed_id, string $contentType = self::contentTypes['refreshFeed'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling refreshFeed' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FeedsApi.refreshFeed, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling refreshFeed' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/refresh'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setFeedParams + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function setFeedParams($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams'][0]) + { + list($response) = $this->setFeedParamsWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType); + return $response; + } + + /** + * Operation setFeedParamsWithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function setFeedParamsWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams'][0]) + { + $request = $this->setFeedParamsRequest($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setFeedParamsAsync + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParamsAsync($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams'][0]) + { + return $this->setFeedParamsAsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setFeedParamsAsyncWithHttpInfo + * + * Изменение параметров прайс-листа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function setFeedParamsAsyncWithHttpInfo($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setFeedParamsRequest($campaign_id, $feed_id, $set_feed_params_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setFeedParams' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (required) + * @param \OpenAPI\Client\Model\SetFeedParamsRequest $set_feed_params_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setFeedParams'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function setFeedParamsRequest($campaign_id, $feed_id, $set_feed_params_request, string $contentType = self::contentTypes['setFeedParams'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setFeedParams' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling FeedsApi.setFeedParams, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'feed_id' is set + if ($feed_id === null || (is_array($feed_id) && count($feed_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $feed_id when calling setFeedParams' + ); + } + + // verify the required parameter 'set_feed_params_request' is set + if ($set_feed_params_request === null || (is_array($set_feed_params_request) && count($set_feed_params_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_feed_params_request when calling setFeedParams' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/feeds/{feedId}/params'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($feed_id !== null) { + $resourcePath = str_replace( + '{' . 'feedId' . '}', + ObjectSerializer::toPathValue($feed_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_feed_params_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_feed_params_request)); + } else { + $httpBody = $set_feed_params_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/GoodsFeedbackApi.php b/erp24/lib/yandex_market_api/Api/GoodsFeedbackApi.php new file mode 100644 index 00000000..54e84a8c --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/GoodsFeedbackApi.php @@ -0,0 +1,2954 @@ + [ + 'application/json', + ], + 'getGoodsFeedbackComments' => [ + 'application/json', + ], + 'getGoodsFeedbacks' => [ + 'application/json', + ], + 'skipGoodsFeedbacksReaction' => [ + 'application/json', + ], + 'updateGoodsFeedbackComment' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation deleteGoodsFeedbackComment + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteGoodsFeedbackComment($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment'][0]) + { + list($response) = $this->deleteGoodsFeedbackCommentWithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation deleteGoodsFeedbackCommentWithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteGoodsFeedbackCommentWithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment'][0]) + { + $request = $this->deleteGoodsFeedbackCommentRequest($business_id, $delete_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteGoodsFeedbackCommentAsync + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackCommentAsync($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment'][0]) + { + return $this->deleteGoodsFeedbackCommentAsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteGoodsFeedbackCommentAsyncWithHttpInfo + * + * Удаление комментария к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteGoodsFeedbackCommentAsyncWithHttpInfo($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteGoodsFeedbackCommentRequest($business_id, $delete_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteGoodsFeedbackComment' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteGoodsFeedbackCommentRequest $delete_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteGoodsFeedbackCommentRequest($business_id, $delete_goods_feedback_comment_request, string $contentType = self::contentTypes['deleteGoodsFeedbackComment'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deleteGoodsFeedbackComment' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling GoodsFeedbackApi.deleteGoodsFeedbackComment, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_goods_feedback_comment_request' is set + if ($delete_goods_feedback_comment_request === null || (is_array($delete_goods_feedback_comment_request) && count($delete_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_goods_feedback_comment_request when calling deleteGoodsFeedbackComment' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_goods_feedback_comment_request)); + } else { + $httpBody = $delete_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbackComments + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbackComments($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments'][0]) + { + list($response) = $this->getGoodsFeedbackCommentsWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbackCommentsWithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbackCommentsWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments'][0]) + { + $request = $this->getGoodsFeedbackCommentsRequest($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbackCommentsAsync + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackCommentsAsync($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments'][0]) + { + return $this->getGoodsFeedbackCommentsAsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbackCommentsAsyncWithHttpInfo + * + * Получение комментариев к отзыву + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbackCommentsAsyncWithHttpInfo($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackCommentsResponse'; + $request = $this->getGoodsFeedbackCommentsRequest($business_id, $get_goods_feedback_comments_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbackComments' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackCommentsRequest $get_goods_feedback_comments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbackComments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbackCommentsRequest($business_id, $get_goods_feedback_comments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getGoodsFeedbackComments'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbackComments' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling GoodsFeedbackApi.getGoodsFeedbackComments, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_feedback_comments_request' is set + if ($get_goods_feedback_comments_request === null || (is_array($get_goods_feedback_comments_request) && count($get_goods_feedback_comments_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_feedback_comments_request when calling getGoodsFeedbackComments' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_comments_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_comments_request)); + } else { + $httpBody = $get_goods_feedback_comments_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getGoodsFeedbacks + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsFeedbacks($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks'][0]) + { + list($response) = $this->getGoodsFeedbacksWithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + return $response; + } + + /** + * Operation getGoodsFeedbacksWithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsFeedbackResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsFeedbacksWithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks'][0]) + { + $request = $this->getGoodsFeedbacksRequest($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsFeedbackResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsFeedbackResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsFeedbacksAsync + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacksAsync($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks'][0]) + { + return $this->getGoodsFeedbacksAsyncWithHttpInfo($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsFeedbacksAsyncWithHttpInfo + * + * Получение отзывов о товарах продавца + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsFeedbacksAsyncWithHttpInfo($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsFeedbackResponse'; + $request = $this->getGoodsFeedbacksRequest($business_id, $page_token, $limit, $get_goods_feedback_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsFeedbacks' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetGoodsFeedbackRequest $get_goods_feedback_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsFeedbacks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsFeedbacksRequest($business_id, $page_token = null, $limit = null, $get_goods_feedback_request = null, string $contentType = self::contentTypes['getGoodsFeedbacks'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getGoodsFeedbacks' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling GoodsFeedbackApi.getGoodsFeedbacks, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/businesses/{businessId}/goods-feedback'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_feedback_request)); + } else { + $httpBody = $get_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation skipGoodsFeedbacksReaction + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function skipGoodsFeedbacksReaction($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction'][0]) + { + list($response) = $this->skipGoodsFeedbacksReactionWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType); + return $response; + } + + /** + * Operation skipGoodsFeedbacksReactionWithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function skipGoodsFeedbacksReactionWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction'][0]) + { + $request = $this->skipGoodsFeedbacksReactionRequest($business_id, $skip_goods_feedback_reaction_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation skipGoodsFeedbacksReactionAsync + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReactionAsync($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction'][0]) + { + return $this->skipGoodsFeedbacksReactionAsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation skipGoodsFeedbacksReactionAsyncWithHttpInfo + * + * Отказ от ответа на отзывы + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function skipGoodsFeedbacksReactionAsyncWithHttpInfo($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->skipGoodsFeedbacksReactionRequest($business_id, $skip_goods_feedback_reaction_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'skipGoodsFeedbacksReaction' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SkipGoodsFeedbackReactionRequest $skip_goods_feedback_reaction_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['skipGoodsFeedbacksReaction'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function skipGoodsFeedbacksReactionRequest($business_id, $skip_goods_feedback_reaction_request, string $contentType = self::contentTypes['skipGoodsFeedbacksReaction'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling skipGoodsFeedbacksReaction' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling GoodsFeedbackApi.skipGoodsFeedbacksReaction, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'skip_goods_feedback_reaction_request' is set + if ($skip_goods_feedback_reaction_request === null || (is_array($skip_goods_feedback_reaction_request) && count($skip_goods_feedback_reaction_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $skip_goods_feedback_reaction_request when calling skipGoodsFeedbacksReaction' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/skip-reaction'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($skip_goods_feedback_reaction_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($skip_goods_feedback_reaction_request)); + } else { + $httpBody = $skip_goods_feedback_reaction_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateGoodsFeedbackComment + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateGoodsFeedbackComment($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment'][0]) + { + list($response) = $this->updateGoodsFeedbackCommentWithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType); + return $response; + } + + /** + * Operation updateGoodsFeedbackCommentWithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateGoodsFeedbackCommentWithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment'][0]) + { + $request = $this->updateGoodsFeedbackCommentRequest($business_id, $update_goods_feedback_comment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateGoodsFeedbackCommentAsync + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackCommentAsync($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment'][0]) + { + return $this->updateGoodsFeedbackCommentAsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateGoodsFeedbackCommentAsyncWithHttpInfo + * + * Добавление нового или изменение созданного комментария + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateGoodsFeedbackCommentAsyncWithHttpInfo($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentResponse'; + $request = $this->updateGoodsFeedbackCommentRequest($business_id, $update_goods_feedback_comment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateGoodsFeedbackComment' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentRequest $update_goods_feedback_comment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateGoodsFeedbackComment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateGoodsFeedbackCommentRequest($business_id, $update_goods_feedback_comment_request, string $contentType = self::contentTypes['updateGoodsFeedbackComment'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateGoodsFeedbackComment' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling GoodsFeedbackApi.updateGoodsFeedbackComment, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_goods_feedback_comment_request' is set + if ($update_goods_feedback_comment_request === null || (is_array($update_goods_feedback_comment_request) && count($update_goods_feedback_comment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_goods_feedback_comment_request when calling updateGoodsFeedbackComment' + ); + } + + + $resourcePath = '/businesses/{businessId}/goods-feedback/comments/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_goods_feedback_comment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_goods_feedback_comment_request)); + } else { + $httpBody = $update_goods_feedback_comment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/GoodsStatsApi.php b/erp24/lib/yandex_market_api/Api/GoodsStatsApi.php new file mode 100644 index 00000000..4b155c8b --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/GoodsStatsApi.php @@ -0,0 +1,692 @@ + [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getGoodsStats + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getGoodsStats($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats'][0]) + { + list($response) = $this->getGoodsStatsWithHttpInfo($campaign_id, $get_goods_stats_request, $contentType); + return $response; + } + + /** + * Operation getGoodsStatsWithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetGoodsStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getGoodsStatsWithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats'][0]) + { + $request = $this->getGoodsStatsRequest($campaign_id, $get_goods_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetGoodsStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetGoodsStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetGoodsStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getGoodsStatsAsync + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStatsAsync($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats'][0]) + { + return $this->getGoodsStatsAsyncWithHttpInfo($campaign_id, $get_goods_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getGoodsStatsAsyncWithHttpInfo + * + * Отчет по товарам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getGoodsStatsAsyncWithHttpInfo($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetGoodsStatsResponse'; + $request = $this->getGoodsStatsRequest($campaign_id, $get_goods_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getGoodsStats' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetGoodsStatsRequest $get_goods_stats_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getGoodsStats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getGoodsStatsRequest($campaign_id, $get_goods_stats_request, string $contentType = self::contentTypes['getGoodsStats'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getGoodsStats' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling GoodsStatsApi.getGoodsStats, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_goods_stats_request' is set + if ($get_goods_stats_request === null || (is_array($get_goods_stats_request) && count($get_goods_stats_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_goods_stats_request when calling getGoodsStats' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/stats/skus'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_goods_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_goods_stats_request)); + } else { + $httpBody = $get_goods_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/HiddenOffersApi.php b/erp24/lib/yandex_market_api/Api/HiddenOffersApi.php new file mode 100644 index 00000000..f7d3a173 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/HiddenOffersApi.php @@ -0,0 +1,1870 @@ + [ + 'application/json', + ], + 'deleteHiddenOffers' => [ + 'application/json', + ], + 'getHiddenOffers' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addHiddenOffers + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function addHiddenOffers($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers'][0]) + { + list($response) = $this->addHiddenOffersWithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation addHiddenOffersWithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function addHiddenOffersWithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers'][0]) + { + $request = $this->addHiddenOffersRequest($campaign_id, $add_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation addHiddenOffersAsync + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffersAsync($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers'][0]) + { + return $this->addHiddenOffersAsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addHiddenOffersAsyncWithHttpInfo + * + * Скрытие товаров и настройки скрытия + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addHiddenOffersAsyncWithHttpInfo($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->addHiddenOffersRequest($campaign_id, $add_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addHiddenOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\AddHiddenOffersRequest $add_hidden_offers_request Запрос на скрытие оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function addHiddenOffersRequest($campaign_id, $add_hidden_offers_request, string $contentType = self::contentTypes['addHiddenOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling addHiddenOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling HiddenOffersApi.addHiddenOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'add_hidden_offers_request' is set + if ($add_hidden_offers_request === null || (is_array($add_hidden_offers_request) && count($add_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $add_hidden_offers_request when calling addHiddenOffers' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($add_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($add_hidden_offers_request)); + } else { + $httpBody = $add_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteHiddenOffers + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteHiddenOffers($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers'][0]) + { + list($response) = $this->deleteHiddenOffersWithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteHiddenOffersWithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteHiddenOffersWithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers'][0]) + { + $request = $this->deleteHiddenOffersRequest($campaign_id, $delete_hidden_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteHiddenOffersAsync + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffersAsync($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers'][0]) + { + return $this->deleteHiddenOffersAsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteHiddenOffersAsyncWithHttpInfo + * + * Возобновление показа товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteHiddenOffersAsyncWithHttpInfo($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteHiddenOffersRequest($campaign_id, $delete_hidden_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteHiddenOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteHiddenOffersRequest $delete_hidden_offers_request Запрос на возобновление показа оферов. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteHiddenOffersRequest($campaign_id, $delete_hidden_offers_request, string $contentType = self::contentTypes['deleteHiddenOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteHiddenOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling HiddenOffersApi.deleteHiddenOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_hidden_offers_request' is set + if ($delete_hidden_offers_request === null || (is_array($delete_hidden_offers_request) && count($delete_hidden_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_hidden_offers_request when calling deleteHiddenOffers' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_hidden_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_hidden_offers_request)); + } else { + $httpBody = $delete_hidden_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getHiddenOffers + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getHiddenOffers($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers'][0]) + { + list($response) = $this->getHiddenOffersWithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getHiddenOffersWithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetHiddenOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getHiddenOffersWithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers'][0]) + { + $request = $this->getHiddenOffersRequest($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetHiddenOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetHiddenOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetHiddenOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getHiddenOffersAsync + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffersAsync($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers'][0]) + { + return $this->getHiddenOffersAsyncWithHttpInfo($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getHiddenOffersAsyncWithHttpInfo + * + * Информация о скрытых вами товарах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getHiddenOffersAsyncWithHttpInfo($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetHiddenOffersResponse'; + $request = $this->getHiddenOffersRequest($campaign_id, $offer_id, $page_token, $limit, $offset, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getHiddenOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор скрытого предложения. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int $offset Позиция в списке, начиная с которой возвращаются результаты ответа. Используется вместе с параметром `limit`. Если задан `offset`, параметры `page_number` и `page_size` игнорируются. `offset` игнорируется, если задан `page_token`. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getHiddenOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getHiddenOffersRequest($campaign_id, $offer_id = null, $page_token = null, $limit = null, $offset = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getHiddenOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getHiddenOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling HiddenOffersApi.getHiddenOffers, must be bigger than or equal to 1.'); + } + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling HiddenOffersApi.getHiddenOffers, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/hidden-offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offset, + 'offset', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/ModelsApi.php b/erp24/lib/yandex_market_api/Api/ModelsApi.php new file mode 100644 index 00000000..3cce497a --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/ModelsApi.php @@ -0,0 +1,3071 @@ + [ + 'application/json', + ], + 'getModelOffers' => [ + 'application/json', + ], + 'getModels' => [ + 'application/json', + ], + 'getModelsOffers' => [ + 'application/json', + ], + 'searchModels' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getModel + * + * Информация об одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getModel($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel'][0]) + { + list($response) = $this->getModelWithHttpInfo($model_id, $region_id, $currency, $contentType); + return $response; + } + + /** + * Operation getModelWithHttpInfo + * + * Информация об одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getModelWithHttpInfo($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel'][0]) + { + $request = $this->getModelRequest($model_id, $region_id, $currency, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetModelsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetModelsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetModelsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetModelsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetModelsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getModelAsync + * + * Информация об одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelAsync($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel'][0]) + { + return $this->getModelAsyncWithHttpInfo($model_id, $region_id, $currency, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getModelAsyncWithHttpInfo + * + * Информация об одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelAsyncWithHttpInfo($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetModelsResponse'; + $request = $this->getModelRequest($model_id, $region_id, $currency, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getModel' + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModel'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getModelRequest($model_id, $region_id, $currency = null, string $contentType = self::contentTypes['getModel'][0]) + { + + // verify the required parameter 'model_id' is set + if ($model_id === null || (is_array($model_id) && count($model_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $model_id when calling getModel' + ); + } + if ($model_id <= 0) { + throw new \InvalidArgumentException('invalid value for "$model_id" when calling ModelsApi.getModel, must be bigger than 0.'); + } + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling getModel' + ); + } + + + + $resourcePath = '/models/{modelId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($model_id !== null) { + $resourcePath = str_replace( + '{' . 'modelId' . '}', + ObjectSerializer::toPathValue($model_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getModelOffers + * + * Список предложений для одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetModelsOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getModelOffers($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers'][0]) + { + list($response) = $this->getModelOffersWithHttpInfo($model_id, $region_id, $currency, $order_by_price, $count, $page, $contentType); + return $response; + } + + /** + * Operation getModelOffersWithHttpInfo + * + * Список предложений для одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetModelsOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getModelOffersWithHttpInfo($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers'][0]) + { + $request = $this->getModelOffersRequest($model_id, $region_id, $currency, $order_by_price, $count, $page, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetModelsOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetModelsOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetModelsOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetModelsOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetModelsOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getModelOffersAsync + * + * Список предложений для одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelOffersAsync($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers'][0]) + { + return $this->getModelOffersAsyncWithHttpInfo($model_id, $region_id, $currency, $order_by_price, $count, $page, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getModelOffersAsyncWithHttpInfo + * + * Список предложений для одной модели + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelOffersAsyncWithHttpInfo($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetModelsOffersResponse'; + $request = $this->getModelOffersRequest($model_id, $region_id, $currency, $order_by_price, $count, $page, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getModelOffers' + * + * @param int $model_id Идентификатор модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param int $count Количество предложений на странице ответа. (optional, default to 10) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getModelOffersRequest($model_id, $region_id, $currency = null, $order_by_price = null, $count = 10, $page = 1, string $contentType = self::contentTypes['getModelOffers'][0]) + { + + // verify the required parameter 'model_id' is set + if ($model_id === null || (is_array($model_id) && count($model_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $model_id when calling getModelOffers' + ); + } + if ($model_id <= 0) { + throw new \InvalidArgumentException('invalid value for "$model_id" when calling ModelsApi.getModelOffers, must be bigger than 0.'); + } + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling getModelOffers' + ); + } + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling ModelsApi.getModelOffers, must be smaller than or equal to 10000.'); + } + + + $resourcePath = '/models/{modelId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_by_price, + 'orderByPrice', // param base name + 'SortOrderType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $count, + 'count', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($model_id !== null) { + $resourcePath = str_replace( + '{' . 'modelId' . '}', + ObjectSerializer::toPathValue($model_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getModels + * + * Информация о нескольких моделях + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getModels($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels'][0]) + { + list($response) = $this->getModelsWithHttpInfo($region_id, $get_models_request, $currency, $contentType); + return $response; + } + + /** + * Operation getModelsWithHttpInfo + * + * Информация о нескольких моделях + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getModelsWithHttpInfo($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels'][0]) + { + $request = $this->getModelsRequest($region_id, $get_models_request, $currency, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetModelsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetModelsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetModelsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetModelsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetModelsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getModelsAsync + * + * Информация о нескольких моделях + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelsAsync($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels'][0]) + { + return $this->getModelsAsyncWithHttpInfo($region_id, $get_models_request, $currency, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getModelsAsyncWithHttpInfo + * + * Информация о нескольких моделях + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelsAsyncWithHttpInfo($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetModelsResponse'; + $request = $this->getModelsRequest($region_id, $get_models_request, $currency, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getModels' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getModelsRequest($region_id, $get_models_request, $currency = null, string $contentType = self::contentTypes['getModels'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling getModels' + ); + } + + // verify the required parameter 'get_models_request' is set + if ($get_models_request === null || (is_array($get_models_request) && count($get_models_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_models_request when calling getModels' + ); + } + + + + $resourcePath = '/models'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_models_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_models_request)); + } else { + $httpBody = $get_models_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getModelsOffers + * + * Список предложений для нескольких моделей + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetModelsOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getModelsOffers($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers'][0]) + { + list($response) = $this->getModelsOffersWithHttpInfo($region_id, $get_models_request, $currency, $order_by_price, $contentType); + return $response; + } + + /** + * Operation getModelsOffersWithHttpInfo + * + * Список предложений для нескольких моделей + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetModelsOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getModelsOffersWithHttpInfo($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers'][0]) + { + $request = $this->getModelsOffersRequest($region_id, $get_models_request, $currency, $order_by_price, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetModelsOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetModelsOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetModelsOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetModelsOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetModelsOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getModelsOffersAsync + * + * Список предложений для нескольких моделей + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelsOffersAsync($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers'][0]) + { + return $this->getModelsOffersAsyncWithHttpInfo($region_id, $get_models_request, $currency, $order_by_price, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getModelsOffersAsyncWithHttpInfo + * + * Список предложений для нескольких моделей + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getModelsOffersAsyncWithHttpInfo($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetModelsOffersResponse'; + $request = $this->getModelsOffersRequest($region_id, $get_models_request, $currency, $order_by_price, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getModelsOffers' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\GetModelsRequest $get_models_request (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param \OpenAPI\Client\Model\SortOrderType $order_by_price Направление сортировки по цене. Возможные значения: * `ASC` — сортировка по возрастанию. * `DESC` — сортировка по убыванию. Значение по умолчанию: предложения выводятся в произвольном порядке. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getModelsOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getModelsOffersRequest($region_id, $get_models_request, $currency = null, $order_by_price = null, string $contentType = self::contentTypes['getModelsOffers'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling getModelsOffers' + ); + } + + // verify the required parameter 'get_models_request' is set + if ($get_models_request === null || (is_array($get_models_request) && count($get_models_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_models_request when calling getModelsOffers' + ); + } + + + + + $resourcePath = '/models/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_by_price, + 'orderByPrice', // param base name + 'SortOrderType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_models_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_models_request)); + } else { + $httpBody = $get_models_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchModels + * + * Поиск модели товара + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SearchModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchModels($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels'][0]) + { + list($response) = $this->searchModelsWithHttpInfo($query, $region_id, $currency, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation searchModelsWithHttpInfo + * + * Поиск модели товара + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SearchModelsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchModelsWithHttpInfo($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels'][0]) + { + $request = $this->searchModelsRequest($query, $region_id, $currency, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SearchModelsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SearchModelsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SearchModelsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SearchModelsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SearchModelsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchModelsAsync + * + * Поиск модели товара + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchModelsAsync($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels'][0]) + { + return $this->searchModelsAsyncWithHttpInfo($query, $region_id, $currency, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchModelsAsyncWithHttpInfo + * + * Поиск модели товара + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchModelsAsyncWithHttpInfo($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels'][0]) + { + $returnType = '\OpenAPI\Client\Model\SearchModelsResponse'; + $request = $this->searchModelsRequest($query, $region_id, $currency, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchModels' + * + * @param string $query Поисковый запрос по названию модели товара. (required) + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой отображаются цены предложений на страницах с результатами поиска. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. Значение по умолчанию: используется национальная валюта магазина (национальная валюта страны происхождения магазина). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchModels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchModelsRequest($query, $region_id, $currency = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchModels'][0]) + { + + // verify the required parameter 'query' is set + if ($query === null || (is_array($query) && count($query) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $query when calling searchModels' + ); + } + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchModels' + ); + } + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling ModelsApi.searchModels, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/models'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OfferMappingsApi.php b/erp24/lib/yandex_market_api/Api/OfferMappingsApi.php new file mode 100644 index 00000000..91850027 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OfferMappingsApi.php @@ -0,0 +1,1962 @@ + [ + 'application/json', + ], + 'getSuggestedOfferMappingEntries' => [ + 'application/json', + ], + 'updateOfferMappingEntries' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getOfferMappingEntries + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOfferMappingEntries($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries'][0]) + { + list($response) = $this->getOfferMappingEntriesWithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferMappingEntriesWithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOfferMappingEntriesWithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries'][0]) + { + $request = $this->getOfferMappingEntriesRequest($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferMappingEntriesAsync + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntriesAsync($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries'][0]) + { + return $this->getOfferMappingEntriesAsyncWithHttpInfo($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferMappingEntriesAsyncWithHttpInfo + * + * Список товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOfferMappingEntriesAsyncWithHttpInfo($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferMappingEntriesResponse'; + $request = $this->getOfferMappingEntriesRequest($campaign_id, $offer_id, $shop_sku, $mapping_kind, $status, $availability, $category_id, $vendor, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferMappingEntries' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string[] $offer_id Идентификатор товара в каталоге. (optional) + * @param string[] $shop_sku Ваш SKU товара. Параметр может быть указан несколько раз, например: ``` ...shop_sku=123&shop_sku=129&shop_sku=141... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferMappingKindType $mapping_kind Тип маппинга. (optional) + * @param \OpenAPI\Client\Model\OfferProcessingStatusType[] $status Фильтрация по статусу публикации товара: * `READY` — товар прошел модерацию. * `IN_WORK` — товар проходит модерацию. * `NEED_CONTENT` — для товара без SKU на Маркете marketSku нужно найти карточку самостоятельно или создать ее. * `NEED_INFO` — товар не прошел модерацию из-за ошибок или недостающих сведений в описании товара. * `REJECTED` — товар не прошел модерацию, так как Маркет не планирует размещать подобные товары. * `SUSPENDED` — товар не прошел модерацию, так как Маркет пока не размещает подобные товары. * `OTHER` — товар не прошел модерацию по другой причине. Можно указать несколько статусов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...status=READY,IN_WORK... ...status=READY&status=IN_WORK... ``` В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType[] $availability Фильтрация по планам поставок товара: * `ACTIVE` — поставки будут. * `INACTIVE` — поставок не будет: товар есть на складе, но вы больше не планируете его поставлять. * `DELISTED` — архив: товар закончился на складе, и его поставок больше не будет. Можно указать несколько значений в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...availability=INACTIVE,DELISTED... ...availability=INACTIVE&availability=DELISTED... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param int[] $category_id Фильтрация по идентификатору категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). Можно указать несколько идентификаторов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...category_id=14727164,14382343... ...category_id=14727164&category_id=14382343... ``` В запросе можно указать либо параметр `shopSku`, либо любые параметры для фильтрации товаров. Совместное использование параметра `shopSku` и параметров для фильтрации приведет к ошибке. (optional) + * @param string[] $vendor Фильтрация по бренду товара. Можно указать несколько брендов в одном параметре, через запятую, или в нескольких одинаковых параметрах. Например: ``` ...vendor=Aqua%20Minerale,Borjomi... ...vendor=Aqua%20Minerale&vendor=Borjomi... ``` Чтобы товар попал в результаты фильтрации, его бренд должен точно совпадать с одним из указанных в запросе. Например, если указан бренд Schwarzkopf, то в результатах не будет товаров Schwarzkopf Professional. Если в названии бренда есть символы, которые не входят в таблицу ASCII (в том числе кириллические символы), используйте для них URL-кодирование. Например, пробел — %20, апостроф «'» — %27 и т. д. Подробнее см. в разделе [Кодирование URL русскоязычной Википедии](https://ru.wikipedia.org/wiki/URL#Кодирование_URL). В запросе можно указать либо параметр shopSku, либо любые параметры для фильтрации товаров. Совместное использование параметра shopSku и параметров для фильтрации приведет к ошибке. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOfferMappingEntriesRequest($campaign_id, $offer_id = null, $shop_sku = null, $mapping_kind = null, $status = null, $availability = null, $category_id = null, $vendor = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferMappingEntries'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOfferMappingEntries' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OfferMappingsApi.getOfferMappingEntries, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $offer_id, + 'offer_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_sku, + 'shop_sku', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $mapping_kind, + 'mapping_kind', // param base name + 'OfferMappingKindType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $availability, + 'availability', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $category_id, + 'category_id', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $vendor, + 'vendor', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedOfferMappingEntries + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedOfferMappingEntries($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries'][0]) + { + list($response) = $this->getSuggestedOfferMappingEntriesWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedOfferMappingEntriesWithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedOfferMappingEntriesWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries'][0]) + { + $request = $this->getSuggestedOfferMappingEntriesRequest($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedOfferMappingEntriesAsync + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntriesAsync($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries'][0]) + { + return $this->getSuggestedOfferMappingEntriesAsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedOfferMappingEntriesAsyncWithHttpInfo + * + * Рекомендованные карточки для товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedOfferMappingEntriesAsyncWithHttpInfo($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesResponse'; + $request = $this->getSuggestedOfferMappingEntriesRequest($campaign_id, $get_suggested_offer_mapping_entries_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedOfferMappingEntries' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingEntriesRequest $get_suggested_offer_mapping_entries_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedOfferMappingEntriesRequest($campaign_id, $get_suggested_offer_mapping_entries_request, string $contentType = self::contentTypes['getSuggestedOfferMappingEntries'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedOfferMappingEntries' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OfferMappingsApi.getSuggestedOfferMappingEntries, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_suggested_offer_mapping_entries_request' is set + if ($get_suggested_offer_mapping_entries_request === null || (is_array($get_suggested_offer_mapping_entries_request) && count($get_suggested_offer_mapping_entries_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_suggested_offer_mapping_entries_request when calling getSuggestedOfferMappingEntries' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_suggested_offer_mapping_entries_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_suggested_offer_mapping_entries_request)); + } else { + $httpBody = $get_suggested_offer_mapping_entries_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOfferMappingEntries + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function updateOfferMappingEntries($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries'][0]) + { + list($response) = $this->updateOfferMappingEntriesWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType); + return $response; + } + + /** + * Operation updateOfferMappingEntriesWithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function updateOfferMappingEntriesWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries'][0]) + { + $request = $this->updateOfferMappingEntriesRequest($campaign_id, $update_offer_mapping_entry_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOfferMappingEntriesAsync + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntriesAsync($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries'][0]) + { + return $this->updateOfferMappingEntriesAsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOfferMappingEntriesAsyncWithHttpInfo + * + * Добавление и редактирование товаров в каталоге + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function updateOfferMappingEntriesAsyncWithHttpInfo($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOfferMappingEntriesRequest($campaign_id, $update_offer_mapping_entry_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOfferMappingEntries' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryRequest $update_offer_mapping_entry_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOfferMappingEntries'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function updateOfferMappingEntriesRequest($campaign_id, $update_offer_mapping_entry_request, string $contentType = self::contentTypes['updateOfferMappingEntries'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOfferMappingEntries' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OfferMappingsApi.updateOfferMappingEntries, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_offer_mapping_entry_request' is set + if ($update_offer_mapping_entry_request === null || (is_array($update_offer_mapping_entry_request) && count($update_offer_mapping_entry_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_offer_mapping_entry_request when calling updateOfferMappingEntries' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-mapping-entries/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_offer_mapping_entry_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_offer_mapping_entry_request)); + } else { + $httpBody = $update_offer_mapping_entry_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OffersApi.php b/erp24/lib/yandex_market_api/Api/OffersApi.php new file mode 100644 index 00000000..33863068 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OffersApi.php @@ -0,0 +1,3692 @@ + [ + 'application/json', + ], + 'getAllOffers' => [ + 'application/json', + ], + 'getCampaignOffers' => [ + 'application/json', + ], + 'getOfferRecommendations' => [ + 'application/json', + ], + 'getOffers' => [ + 'application/json', + ], + 'updateCampaignOffers' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation deleteCampaignOffers + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteCampaignOffers($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers'][0]) + { + list($response) = $this->deleteCampaignOffersWithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation deleteCampaignOffersWithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeleteCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteCampaignOffersWithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers'][0]) + { + $request = $this->deleteCampaignOffersRequest($campaign_id, $delete_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeleteCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeleteCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteCampaignOffersAsync + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffersAsync($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers'][0]) + { + return $this->deleteCampaignOffersAsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteCampaignOffersAsyncWithHttpInfo + * + * Удаление товаров из ассортимента магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteCampaignOffersAsyncWithHttpInfo($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeleteCampaignOffersResponse'; + $request = $this->deleteCampaignOffersRequest($campaign_id, $delete_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteCampaignOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeleteCampaignOffersRequest $delete_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteCampaignOffersRequest($campaign_id, $delete_campaign_offers_request, string $contentType = self::contentTypes['deleteCampaignOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteCampaignOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OffersApi.deleteCampaignOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_campaign_offers_request' is set + if ($delete_campaign_offers_request === null || (is_array($delete_campaign_offers_request) && count($delete_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_campaign_offers_request when calling deleteCampaignOffers' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_campaign_offers_request)); + } else { + $httpBody = $delete_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getAllOffers + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getAllOffers($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers'][0]) + { + list($response) = $this->getAllOffersWithHttpInfo($campaign_id, $feed_id, $chunk, $contentType); + return $response; + } + + /** + * Operation getAllOffersWithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetAllOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getAllOffersWithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers'][0]) + { + $request = $this->getAllOffersRequest($campaign_id, $feed_id, $chunk, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetAllOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetAllOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetAllOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetAllOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getAllOffersAsync + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffersAsync($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers'][0]) + { + return $this->getAllOffersAsyncWithHttpInfo($campaign_id, $feed_id, $chunk, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getAllOffersAsyncWithHttpInfo + * + * Все предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getAllOffersAsyncWithHttpInfo($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetAllOffersResponse'; + $request = $this->getAllOffersRequest($campaign_id, $feed_id, $chunk, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getAllOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param int $chunk Номер сегмента с результатами. Значение по умолчанию: `0`. {% note info %} Номера сегментов запрашиваются последовательно, пока не будет получен сегмент с пустым ответом. Пустой ответ означает, что все предложения магазина получены. {% endnote %} {% note alert %} Нумерация начинается с 0. Чтобы запросить первую страницу, необходимо указать `chunk=0` и т. д. {% endnote %} (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getAllOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getAllOffersRequest($campaign_id, $feed_id = null, $chunk = null, string $contentType = self::contentTypes['getAllOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getAllOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OffersApi.getAllOffers, must be bigger than or equal to 1.'); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers/all'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $chunk, + 'chunk', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignOffers + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignOffers($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers'][0]) + { + list($response) = $this->getCampaignOffersWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignOffersWithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetCampaignOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignOffersWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers'][0]) + { + $request = $this->getCampaignOffersRequest($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetCampaignOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetCampaignOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetCampaignOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignOffersAsync + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffersAsync($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers'][0]) + { + return $this->getCampaignOffersAsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignOffersAsyncWithHttpInfo + * + * Информация о товарах, которые размещены в заданном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignOffersAsyncWithHttpInfo($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetCampaignOffersResponse'; + $request = $this->getCampaignOffersRequest($campaign_id, $get_campaign_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetCampaignOffersRequest $get_campaign_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignOffersRequest($campaign_id, $get_campaign_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OffersApi.getCampaignOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_campaign_offers_request' is set + if ($get_campaign_offers_request === null || (is_array($get_campaign_offers_request) && count($get_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_campaign_offers_request when calling getCampaignOffers' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_campaign_offers_request)); + } else { + $httpBody = $get_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOfferRecommendations + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOfferRecommendations($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations'][0]) + { + list($response) = $this->getOfferRecommendationsWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOfferRecommendationsWithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOfferRecommendationsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOfferRecommendationsWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations'][0]) + { + $request = $this->getOfferRecommendationsRequest($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOfferRecommendationsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOfferRecommendationsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOfferRecommendationsAsync + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendationsAsync($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations'][0]) + { + return $this->getOfferRecommendationsAsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOfferRecommendationsAsyncWithHttpInfo + * + * Рекомендации Маркета, касающиеся цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOfferRecommendationsAsyncWithHttpInfo($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOfferRecommendationsResponse'; + $request = $this->getOfferRecommendationsRequest($business_id, $get_offer_recommendations_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOfferRecommendations' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetOfferRecommendationsRequest $get_offer_recommendations_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOfferRecommendations'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOfferRecommendationsRequest($business_id, $get_offer_recommendations_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOfferRecommendations'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getOfferRecommendations' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling OffersApi.getOfferRecommendations, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_offer_recommendations_request' is set + if ($get_offer_recommendations_request === null || (is_array($get_offer_recommendations_request) && count($get_offer_recommendations_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_offer_recommendations_request when calling getOfferRecommendations' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/offers/recommendations'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_offer_recommendations_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_offer_recommendations_request)); + } else { + $httpBody = $get_offer_recommendations_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOffers + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getOffers($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers'][0]) + { + list($response) = $this->getOffersWithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation getOffersWithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getOffersWithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers'][0]) + { + $request = $this->getOffersRequest($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOffersAsync + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffersAsync($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers'][0]) + { + return $this->getOffersAsyncWithHttpInfo($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOffersAsyncWithHttpInfo + * + * Предложения магазина + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getOffersAsyncWithHttpInfo($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOffersResponse'; + $request = $this->getOffersRequest($campaign_id, $query, $feed_id, $shop_category_id, $currency, $matched, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $query Поисковый запрос. Поддерживается язык запросов. Значение по умолчанию: все предложения магазина, размещенные на Маркете. (optional) + * @param int $feed_id Идентификатор прайс-листа. (optional) + * @param string $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. (optional) + * @param \OpenAPI\Client\Model\CurrencyType $currency Валюта, в которой указана цена предложения. Возможные значения: * `BYN` — белорусский рубль. * `KZT` — казахстанский тенге. * `RUR` — российский рубль. * `UAH` — украинская гривна. (optional) + * @param bool $matched Фильтр по признаку соотнесения предложения и карточки модели. Возможные значения: * `0 / FALSE / NO` — поиск выполняется среди предложений, не соотнесенных ни с какой карточкой модели. * `1 / TRUE / YES` — поиск выполняется среди предложений, соотнесенных с карточками моделей). (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getOffersRequest($campaign_id, $query = null, $feed_id = null, $shop_category_id = null, $currency = null, $matched = null, $page = 1, $page_size = null, string $contentType = self::contentTypes['getOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OffersApi.getOffers, must be bigger than or equal to 1.'); + } + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling OffersApi.getOffers, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $query, + 'query', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $feed_id, + 'feedId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_category_id, + 'shopCategoryId', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $currency, + 'currency', // param base name + 'CurrencyType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $matched, + 'matched', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateCampaignOffers + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateCampaignOffers($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers'][0]) + { + list($response) = $this->updateCampaignOffersWithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType); + return $response; + } + + /** + * Operation updateCampaignOffersWithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateCampaignOffersWithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers'][0]) + { + $request = $this->updateCampaignOffersRequest($campaign_id, $update_campaign_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateCampaignOffersAsync + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffersAsync($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers'][0]) + { + return $this->updateCampaignOffersAsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateCampaignOffersAsyncWithHttpInfo + * + * Изменение условий продажи товаров в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateCampaignOffersAsyncWithHttpInfo($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateCampaignOffersRequest($campaign_id, $update_campaign_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateCampaignOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateCampaignOffersRequest $update_campaign_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateCampaignOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateCampaignOffersRequest($campaign_id, $update_campaign_offers_request, string $contentType = self::contentTypes['updateCampaignOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateCampaignOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OffersApi.updateCampaignOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_campaign_offers_request' is set + if ($update_campaign_offers_request === null || (is_array($update_campaign_offers_request) && count($update_campaign_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_campaign_offers_request when calling updateCampaignOffers' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_campaign_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_campaign_offers_request)); + } else { + $httpBody = $update_campaign_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OrderBusinessInformationApi.php b/erp24/lib/yandex_market_api/Api/OrderBusinessInformationApi.php new file mode 100644 index 00000000..61a05e20 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OrderBusinessInformationApi.php @@ -0,0 +1,1246 @@ + [ + 'application/json', + ], + 'getOrderBusinessDocumentsInfo' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getOrderBusinessBuyerInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessBuyerInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo'][0]) + { + list($response) = $this->getOrderBusinessBuyerInfoWithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessBuyerInfoWithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessBuyerInfoWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo'][0]) + { + $request = $this->getOrderBusinessBuyerInfoRequest($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessBuyerInfoAsync + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfoAsync($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo'][0]) + { + return $this->getOrderBusinessBuyerInfoAsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessBuyerInfoAsyncWithHttpInfo + * + * Информация о покупателе — юридическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessBuyerInfoAsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessBuyerInfoResponse'; + $request = $this->getOrderBusinessBuyerInfoRequest($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessBuyerInfo' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessBuyerInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessBuyerInfoRequest($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessBuyerInfo'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessBuyerInfo' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderBusinessInformationApi.getOrderBusinessBuyerInfo, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessBuyerInfo' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/business-buyer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderBusinessDocumentsInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBusinessDocumentsInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo'][0]) + { + list($response) = $this->getOrderBusinessDocumentsInfoWithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBusinessDocumentsInfoWithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBusinessDocumentsInfoWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo'][0]) + { + $request = $this->getOrderBusinessDocumentsInfoRequest($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBusinessDocumentsInfoAsync + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfoAsync($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo'][0]) + { + return $this->getOrderBusinessDocumentsInfoAsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBusinessDocumentsInfoAsyncWithHttpInfo + * + * Информация о документах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBusinessDocumentsInfoAsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetBusinessDocumentsInfoResponse'; + $request = $this->getOrderBusinessDocumentsInfoRequest($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBusinessDocumentsInfo' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBusinessDocumentsInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBusinessDocumentsInfoRequest($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBusinessDocumentsInfo'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBusinessDocumentsInfo' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderBusinessInformationApi.getOrderBusinessDocumentsInfo, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBusinessDocumentsInfo' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/documents'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OrderDeliveryApi.php b/erp24/lib/yandex_market_api/Api/OrderDeliveryApi.php new file mode 100644 index 00000000..044a3539 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OrderDeliveryApi.php @@ -0,0 +1,2981 @@ + [ + 'application/json', + ], + 'setOrderDeliveryDate' => [ + 'application/json', + ], + 'setOrderDeliveryTrackCode' => [ + 'application/json', + ], + 'updateOrderStorageLimit' => [ + 'application/json', + ], + 'verifyOrderEac' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getOrderBuyerInfo + * + * Информация о покупателе — физическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderBuyerInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo'][0]) + { + list($response) = $this->getOrderBuyerInfoWithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderBuyerInfoWithHttpInfo + * + * Информация о покупателе — физическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderBuyerInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderBuyerInfoWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo'][0]) + { + $request = $this->getOrderBuyerInfoRequest($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderBuyerInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderBuyerInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderBuyerInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderBuyerInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderBuyerInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderBuyerInfoAsync + * + * Информация о покупателе — физическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBuyerInfoAsync($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo'][0]) + { + return $this->getOrderBuyerInfoAsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderBuyerInfoAsyncWithHttpInfo + * + * Информация о покупателе — физическом лице + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderBuyerInfoAsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderBuyerInfoResponse'; + $request = $this->getOrderBuyerInfoRequest($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderBuyerInfo' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderBuyerInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderBuyerInfoRequest($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderBuyerInfo'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderBuyerInfo' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderDeliveryApi.getOrderBuyerInfo, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderBuyerInfo' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/buyer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderDeliveryDate + * + * Изменение даты доставки заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderDeliveryDate($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate'][0]) + { + list($response) = $this->setOrderDeliveryDateWithHttpInfo($campaign_id, $order_id, $set_order_delivery_date_request, $contentType); + return $response; + } + + /** + * Operation setOrderDeliveryDateWithHttpInfo + * + * Изменение даты доставки заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderDeliveryDateWithHttpInfo($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate'][0]) + { + $request = $this->setOrderDeliveryDateRequest($campaign_id, $order_id, $set_order_delivery_date_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderDeliveryDateAsync + * + * Изменение даты доставки заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderDeliveryDateAsync($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate'][0]) + { + return $this->setOrderDeliveryDateAsyncWithHttpInfo($campaign_id, $order_id, $set_order_delivery_date_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderDeliveryDateAsyncWithHttpInfo + * + * Изменение даты доставки заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderDeliveryDateAsyncWithHttpInfo($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setOrderDeliveryDateRequest($campaign_id, $order_id, $set_order_delivery_date_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderDeliveryDate' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryDateRequest $set_order_delivery_date_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryDate'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderDeliveryDateRequest($campaign_id, $order_id, $set_order_delivery_date_request, string $contentType = self::contentTypes['setOrderDeliveryDate'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderDeliveryDate' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderDeliveryApi.setOrderDeliveryDate, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderDeliveryDate' + ); + } + + // verify the required parameter 'set_order_delivery_date_request' is set + if ($set_order_delivery_date_request === null || (is_array($set_order_delivery_date_request) && count($set_order_delivery_date_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_delivery_date_request when calling setOrderDeliveryDate' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/date'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_delivery_date_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_delivery_date_request)); + } else { + $httpBody = $set_order_delivery_date_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderDeliveryTrackCode + * + * Передача трек‑номера посылки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderDeliveryTrackCode($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode'][0]) + { + list($response) = $this->setOrderDeliveryTrackCodeWithHttpInfo($campaign_id, $order_id, $set_order_delivery_track_code_request, $contentType); + return $response; + } + + /** + * Operation setOrderDeliveryTrackCodeWithHttpInfo + * + * Передача трек‑номера посылки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderDeliveryTrackCodeWithHttpInfo($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode'][0]) + { + $request = $this->setOrderDeliveryTrackCodeRequest($campaign_id, $order_id, $set_order_delivery_track_code_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderDeliveryTrackCodeAsync + * + * Передача трек‑номера посылки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderDeliveryTrackCodeAsync($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode'][0]) + { + return $this->setOrderDeliveryTrackCodeAsyncWithHttpInfo($campaign_id, $order_id, $set_order_delivery_track_code_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderDeliveryTrackCodeAsyncWithHttpInfo + * + * Передача трек‑номера посылки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderDeliveryTrackCodeAsyncWithHttpInfo($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setOrderDeliveryTrackCodeRequest($campaign_id, $order_id, $set_order_delivery_track_code_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderDeliveryTrackCode' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderDeliveryTrackCodeRequest $set_order_delivery_track_code_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderDeliveryTrackCode'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderDeliveryTrackCodeRequest($campaign_id, $order_id, $set_order_delivery_track_code_request, string $contentType = self::contentTypes['setOrderDeliveryTrackCode'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderDeliveryTrackCode' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderDeliveryApi.setOrderDeliveryTrackCode, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderDeliveryTrackCode' + ); + } + + // verify the required parameter 'set_order_delivery_track_code_request' is set + if ($set_order_delivery_track_code_request === null || (is_array($set_order_delivery_track_code_request) && count($set_order_delivery_track_code_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_delivery_track_code_request when calling setOrderDeliveryTrackCode' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/track'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_delivery_track_code_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_delivery_track_code_request)); + } else { + $httpBody = $set_order_delivery_track_code_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStorageLimit + * + * Продление срока хранения заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStorageLimit($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit'][0]) + { + list($response) = $this->updateOrderStorageLimitWithHttpInfo($campaign_id, $order_id, $update_order_storage_limit_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStorageLimitWithHttpInfo + * + * Продление срока хранения заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStorageLimitWithHttpInfo($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit'][0]) + { + $request = $this->updateOrderStorageLimitRequest($campaign_id, $order_id, $update_order_storage_limit_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStorageLimitAsync + * + * Продление срока хранения заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStorageLimitAsync($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit'][0]) + { + return $this->updateOrderStorageLimitAsyncWithHttpInfo($campaign_id, $order_id, $update_order_storage_limit_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStorageLimitAsyncWithHttpInfo + * + * Продление срока хранения заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStorageLimitAsyncWithHttpInfo($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOrderStorageLimitRequest($campaign_id, $order_id, $update_order_storage_limit_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStorageLimit' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStorageLimitRequest $update_order_storage_limit_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStorageLimit'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStorageLimitRequest($campaign_id, $order_id, $update_order_storage_limit_request, string $contentType = self::contentTypes['updateOrderStorageLimit'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStorageLimit' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderDeliveryApi.updateOrderStorageLimit, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderStorageLimit' + ); + } + + // verify the required parameter 'update_order_storage_limit_request' is set + if ($update_order_storage_limit_request === null || (is_array($update_order_storage_limit_request) && count($update_order_storage_limit_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_storage_limit_request when calling updateOrderStorageLimit' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/storage-limit'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_storage_limit_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_storage_limit_request)); + } else { + $httpBody = $update_order_storage_limit_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation verifyOrderEac + * + * Передача кода подтверждения + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\VerifyOrderEacResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function verifyOrderEac($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac'][0]) + { + list($response) = $this->verifyOrderEacWithHttpInfo($campaign_id, $order_id, $verify_order_eac_request, $contentType); + return $response; + } + + /** + * Operation verifyOrderEacWithHttpInfo + * + * Передача кода подтверждения + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\VerifyOrderEacResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function verifyOrderEacWithHttpInfo($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac'][0]) + { + $request = $this->verifyOrderEacRequest($campaign_id, $order_id, $verify_order_eac_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\VerifyOrderEacResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\VerifyOrderEacResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\VerifyOrderEacResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\VerifyOrderEacResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\VerifyOrderEacResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation verifyOrderEacAsync + * + * Передача кода подтверждения + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function verifyOrderEacAsync($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac'][0]) + { + return $this->verifyOrderEacAsyncWithHttpInfo($campaign_id, $order_id, $verify_order_eac_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation verifyOrderEacAsyncWithHttpInfo + * + * Передача кода подтверждения + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function verifyOrderEacAsyncWithHttpInfo($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac'][0]) + { + $returnType = '\OpenAPI\Client\Model\VerifyOrderEacResponse'; + $request = $this->verifyOrderEacRequest($campaign_id, $order_id, $verify_order_eac_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'verifyOrderEac' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\VerifyOrderEacRequest $verify_order_eac_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['verifyOrderEac'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function verifyOrderEacRequest($campaign_id, $order_id, $verify_order_eac_request, string $contentType = self::contentTypes['verifyOrderEac'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling verifyOrderEac' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderDeliveryApi.verifyOrderEac, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling verifyOrderEac' + ); + } + + // verify the required parameter 'verify_order_eac_request' is set + if ($verify_order_eac_request === null || (is_array($verify_order_eac_request) && count($verify_order_eac_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $verify_order_eac_request when calling verifyOrderEac' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/verifyEac'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($verify_order_eac_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($verify_order_eac_request)); + } else { + $httpBody = $verify_order_eac_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OrderLabelsApi.php b/erp24/lib/yandex_market_api/Api/OrderLabelsApi.php new file mode 100644 index 00000000..42ba4535 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OrderLabelsApi.php @@ -0,0 +1,1869 @@ + [ + 'application/json', + ], + 'generateOrderLabels' => [ + 'application/json', + ], + 'getOrderLabelsData' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation generateOrderLabel + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateOrderLabel($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel'][0]) + { + list($response) = $this->generateOrderLabelWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + return $response; + } + + /** + * Operation generateOrderLabelWithHttpInfo + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateOrderLabelWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel'][0]) + { + $request = $this->generateOrderLabelRequest($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateOrderLabelAsync + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabelAsync($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel'][0]) + { + return $this->generateOrderLabelAsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateOrderLabelAsyncWithHttpInfo + * + * Готовый ярлык‑наклейка для коробки в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabelAsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->generateOrderLabelRequest($campaign_id, $order_id, $shipment_id, $box_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateOrderLabel' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Идентификатор грузоместа. (required) + * @param int $box_id Идентификатор коробки. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabel'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateOrderLabelRequest($campaign_id, $order_id, $shipment_id, $box_id, $format = null, string $contentType = self::contentTypes['generateOrderLabel'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling generateOrderLabel' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderLabelsApi.generateOrderLabel, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling generateOrderLabel' + ); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling generateOrderLabel' + ); + } + + // verify the required parameter 'box_id' is set + if ($box_id === null || (is_array($box_id) && count($box_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $box_id when calling generateOrderLabel' + ); + } + + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes/{boxId}/label'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + // path params + if ($box_id !== null) { + $resourcePath = str_replace( + '{' . 'boxId' . '}', + ObjectSerializer::toPathValue($box_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateOrderLabels + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateOrderLabels($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels'][0]) + { + list($response) = $this->generateOrderLabelsWithHttpInfo($campaign_id, $order_id, $format, $contentType); + return $response; + } + + /** + * Operation generateOrderLabelsWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateOrderLabelsWithHttpInfo($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels'][0]) + { + $request = $this->generateOrderLabelsRequest($campaign_id, $order_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateOrderLabelsAsync + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabelsAsync($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels'][0]) + { + return $this->generateOrderLabelsAsyncWithHttpInfo($campaign_id, $order_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateOrderLabelsAsyncWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateOrderLabelsAsyncWithHttpInfo($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->generateOrderLabelsRequest($campaign_id, $order_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateOrderLabels' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A6. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateOrderLabels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateOrderLabelsRequest($campaign_id, $order_id, $format = null, string $contentType = self::contentTypes['generateOrderLabels'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling generateOrderLabels' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderLabelsApi.generateOrderLabels, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling generateOrderLabels' + ); + } + + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/labels'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrderLabelsData + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderLabelsDataResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrderLabelsData($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData'][0]) + { + list($response) = $this->getOrderLabelsDataWithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderLabelsDataWithHttpInfo + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderLabelsDataResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderLabelsDataWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData'][0]) + { + $request = $this->getOrderLabelsDataRequest($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderLabelsDataResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderLabelsDataResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderLabelsDataResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderLabelsDataResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderLabelsDataResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderLabelsDataAsync + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderLabelsDataAsync($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData'][0]) + { + return $this->getOrderLabelsDataAsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderLabelsDataAsyncWithHttpInfo + * + * Данные для самостоятельного изготовления ярлыков + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderLabelsDataAsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderLabelsDataResponse'; + $request = $this->getOrderLabelsDataRequest($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderLabelsData' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderLabelsData'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderLabelsDataRequest($campaign_id, $order_id, string $contentType = self::contentTypes['getOrderLabelsData'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrderLabelsData' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrderLabelsApi.getOrderLabelsData, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderLabelsData' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/labels/data'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OrdersApi.php b/erp24/lib/yandex_market_api/Api/OrdersApi.php new file mode 100644 index 00000000..65c2701d --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OrdersApi.php @@ -0,0 +1,5837 @@ + [ + 'application/json', + ], + 'getOrder' => [ + 'application/json', + ], + 'getOrders' => [ + 'application/json', + ], + 'provideOrderDigitalCodes' => [ + 'application/json', + ], + 'provideOrderItemIdentifiers' => [ + 'application/json', + ], + 'setOrderBoxLayout' => [ + 'application/json', + ], + 'setOrderShipmentBoxes' => [ + 'application/json', + ], + 'updateOrderItems' => [ + 'application/json', + ], + 'updateOrderStatus' => [ + 'application/json', + ], + 'updateOrderStatuses' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation acceptOrderCancellation + * + * Отмена заказа покупателем + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function acceptOrderCancellation($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation'][0]) + { + list($response) = $this->acceptOrderCancellationWithHttpInfo($campaign_id, $order_id, $accept_order_cancellation_request, $contentType); + return $response; + } + + /** + * Operation acceptOrderCancellationWithHttpInfo + * + * Отмена заказа покупателем + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function acceptOrderCancellationWithHttpInfo($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation'][0]) + { + $request = $this->acceptOrderCancellationRequest($campaign_id, $order_id, $accept_order_cancellation_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation acceptOrderCancellationAsync + * + * Отмена заказа покупателем + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function acceptOrderCancellationAsync($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation'][0]) + { + return $this->acceptOrderCancellationAsyncWithHttpInfo($campaign_id, $order_id, $accept_order_cancellation_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation acceptOrderCancellationAsyncWithHttpInfo + * + * Отмена заказа покупателем + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function acceptOrderCancellationAsyncWithHttpInfo($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->acceptOrderCancellationRequest($campaign_id, $order_id, $accept_order_cancellation_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'acceptOrderCancellation' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\AcceptOrderCancellationRequest $accept_order_cancellation_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['acceptOrderCancellation'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function acceptOrderCancellationRequest($campaign_id, $order_id, $accept_order_cancellation_request, string $contentType = self::contentTypes['acceptOrderCancellation'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling acceptOrderCancellation' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.acceptOrderCancellation, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling acceptOrderCancellation' + ); + } + + // verify the required parameter 'accept_order_cancellation_request' is set + if ($accept_order_cancellation_request === null || (is_array($accept_order_cancellation_request) && count($accept_order_cancellation_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $accept_order_cancellation_request when calling acceptOrderCancellation' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/cancellation/accept'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($accept_order_cancellation_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($accept_order_cancellation_request)); + } else { + $httpBody = $accept_order_cancellation_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrder + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrder($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder'][0]) + { + list($response) = $this->getOrderWithHttpInfo($campaign_id, $order_id, $contentType); + return $response; + } + + /** + * Operation getOrderWithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrderResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrderWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder'][0]) + { + $request = $this->getOrderRequest($campaign_id, $order_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrderResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrderResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrderResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrderResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrderAsync + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderAsync($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder'][0]) + { + return $this->getOrderAsyncWithHttpInfo($campaign_id, $order_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrderAsyncWithHttpInfo + * + * Информация об одном заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderAsyncWithHttpInfo($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrderResponse'; + $request = $this->getOrderRequest($campaign_id, $order_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrder' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrder'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrderRequest($campaign_id, $order_id, string $contentType = self::contentTypes['getOrder'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrder' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.getOrder, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrder' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOrders + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrders($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders'][0]) + { + list($response) = $this->getOrdersWithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getOrdersWithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrdersWithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders'][0]) + { + $request = $this->getOrdersRequest($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrdersAsync + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersAsync($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders'][0]) + { + return $this->getOrdersAsyncWithHttpInfo($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrdersAsyncWithHttpInfo + * + * Информация о нескольких заказах + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersAsyncWithHttpInfo($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersResponse'; + $request = $this->getOrdersRequest($campaign_id, $order_ids, $status, $substatus, $from_date, $to_date, $supplier_shipment_date_from, $supplier_shipment_date_to, $updated_at_from, $updated_at_to, $dispatch_type, $fake, $has_cis, $only_waiting_for_cancellation_approve, $only_estimated_delivery, $buyer_type, $page, $page_size, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrders' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $order_ids Фильтрация заказов по идентификаторам. <br><br> ⚠️ Не используйте это поле одновременно с другими фильтрами. Если вы хотите воспользоваться ими, оставьте поле пустым. (optional) + * @param \OpenAPI\Client\Model\OrderStatusType[] $status Статус заказа: * `CANCELLED` — заказ отменен. * `DELIVERED` — заказ получен покупателем. * `DELIVERY` — заказ передан в службу доставки. * `PICKUP` — заказ доставлен в пункт самовывоза. * `PROCESSING` — заказ находится в обработке. * `UNPAID` — заказ оформлен, но еще не оплачен (если выбрана оплата при оформлении). Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \OpenAPI\Client\Model\OrderSubstatusType[] $substatus Этап обработки заказа (если он имеет статус `PROCESSING`) или причина отмены заказа (если он имеет статус `CANCELLED`). Возможные значения для заказа в статусе `PROCESSING`: * `STARTED` — заказ подтвержден, его можно начать обрабатывать. * `READY_TO_SHIP` — заказ собран и готов к отправке. * `SHIPPED` — заказ передан службе доставки. Возможные значения для заказа в статусе `CANCELLED`: * `DELIVERY_SERVICE_UNDELIVERED` — служба доставки не смогла доставить заказ. * `PROCESSING_EXPIRED` — значение более не используется. * `REPLACING_ORDER` — покупатель решил заменить товар другим по собственной инициативе. * `RESERVATION_EXPIRED` — покупатель не завершил оформление зарезервированного заказа в течение 10 минут. * `RESERVATION_FAILED` — Маркет не может продолжить дальнейшую обработку заказа. * `SHOP_FAILED` — магазин не может выполнить заказ. * `USER_CHANGED_MIND` — покупатель отменил заказ по личным причинам. * `USER_NOT_PAID` — покупатель не оплатил заказ (для типа оплаты `PREPAID`) в течение 30 минут. * `USER_REFUSED_DELIVERY` — покупателя не устроили условия доставки. * `USER_REFUSED_PRODUCT` — покупателю не подошел товар. * `USER_REFUSED_QUALITY` — покупателя не устроило качество товара. * `USER_UNREACHABLE` — не удалось связаться с покупателем. Для отмены с этой причиной необходимо выполнить условия: * не менее 3 звонков с 8 до 21 в часовом поясе покупателя; * перерыв между первым и третьим звонком не менее 90 минут; * соединение не короче 5 секунд. Если хотя бы одно из этих условий не выполнено (кроме случая, когда номер недоступен), отменить заказ не получится. Вернется ответ с кодом ошибки 400. * `USER_WANTS_TO_CHANGE_DELIVERY_DATE` — покупатель хочет получить заказ в другой день. * `CANCELLED_COURIER_NOT_FOUND` — не удалось найти курьера. Также могут возвращаться другие значения. Обрабатывать их не требуется. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации заказов по дате оформления. Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `toDate`) должно быть не больше 30 дней. Значение по умолчанию: 30 дней назад от текущей даты. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации заказов по дате оформления. Показываются заказы, созданные до 00:00 указанного дня. Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `fromDate`) и конечной датой должно быть не больше 30 дней. Значение по умолчанию: текущая дата. (optional) + * @param \DateTime $supplier_shipment_date_from Начальная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной и конечной датой (параметр `supplierShipmentDateTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $supplier_shipment_date_to Конечная дата для фильтрации заказов по дате отгрузки в службу доставки (параметр `shipmentDate`). Формат даты: `ДД-ММ-ГГГГ`. Между начальной (параметр `supplierShipmentDateFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_from Начальная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной и конечной датой (параметр `updatedAtTo`) должно быть не больше 30 дней. Начальная дата включается в интервал для фильтрации. (optional) + * @param \DateTime $updated_at_to Конечная дата для фильтрации заказов по дате и времени обновления (параметр `updatedAt`). Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. Между начальной (параметр `updatedAtFrom`) и конечной датой должно быть не больше 30 дней. Конечная дата не включается в интервал для фильтрации. (optional) + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType $dispatch_type Способ отгрузки (optional) + * @param bool $fake Фильтрация заказов по типам: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. (optional, default to false) + * @param bool $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. (optional, default to false) + * @param bool $only_waiting_for_cancellation_approve **Только для модели DBS** Фильтрация заказов по наличию запросов покупателей на отмену. При значение `true` возвращаются только заказы, которые находятся в статусе `DELIVERY` или `PICKUP` и которые пользователи решили отменить. Чтобы подтвердить или отклонить отмену, отправьте запрос [PUT campaigns/{campaignId}/orders/{orderId}/cancellation/accept](../../reference/orders/acceptOrderCancellation). (optional, default to false) + * @param bool $only_estimated_delivery Фильтрация заказов с долгой доставкой (31-60 дней) по подтвержденной дате доставки: * `true` — возвращаются только заказы с неподтвержденной датой доставки. * `false` — фильтрация не применяется. (optional, default to false) + * @param \OpenAPI\Client\Model\OrderBuyerType $buyer_type Фильтрация заказов по типу покупателя. (optional) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrders'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrdersRequest($campaign_id, $order_ids = null, $status = null, $substatus = null, $from_date = null, $to_date = null, $supplier_shipment_date_from = null, $supplier_shipment_date_to = null, $updated_at_from = null, $updated_at_to = null, $dispatch_type = null, $fake = false, $has_cis = false, $only_waiting_for_cancellation_approve = false, $only_estimated_delivery = false, $buyer_type = null, $page = 1, $page_size = null, $page_token = null, $limit = null, string $contentType = self::contentTypes['getOrders'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrders' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.getOrders, must be bigger than or equal to 1.'); + } + + + + + + + + + + + + + + + + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling OrdersApi.getOrders, must be smaller than or equal to 10000.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $status, + 'status', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $substatus, + 'substatus', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_from, + 'supplierShipmentDateFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $supplier_shipment_date_to, + 'supplierShipmentDateTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_from, + 'updatedAtFrom', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $updated_at_to, + 'updatedAtTo', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $dispatch_type, + 'dispatchType', // param base name + 'OrderDeliveryDispatchType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $fake, + 'fake', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $has_cis, + 'hasCis', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_waiting_for_cancellation_approve, + 'onlyWaitingForCancellationApprove', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $only_estimated_delivery, + 'onlyEstimatedDelivery', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $buyer_type, + 'buyerType', // param base name + 'OrderBuyerType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation provideOrderDigitalCodes + * + * Передача ключей цифровых товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function provideOrderDigitalCodes($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes'][0]) + { + list($response) = $this->provideOrderDigitalCodesWithHttpInfo($campaign_id, $order_id, $provide_order_digital_codes_request, $contentType); + return $response; + } + + /** + * Operation provideOrderDigitalCodesWithHttpInfo + * + * Передача ключей цифровых товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function provideOrderDigitalCodesWithHttpInfo($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes'][0]) + { + $request = $this->provideOrderDigitalCodesRequest($campaign_id, $order_id, $provide_order_digital_codes_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation provideOrderDigitalCodesAsync + * + * Передача ключей цифровых товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderDigitalCodesAsync($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes'][0]) + { + return $this->provideOrderDigitalCodesAsyncWithHttpInfo($campaign_id, $order_id, $provide_order_digital_codes_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation provideOrderDigitalCodesAsyncWithHttpInfo + * + * Передача ключей цифровых товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderDigitalCodesAsyncWithHttpInfo($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->provideOrderDigitalCodesRequest($campaign_id, $order_id, $provide_order_digital_codes_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'provideOrderDigitalCodes' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderDigitalCodesRequest $provide_order_digital_codes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderDigitalCodes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function provideOrderDigitalCodesRequest($campaign_id, $order_id, $provide_order_digital_codes_request, string $contentType = self::contentTypes['provideOrderDigitalCodes'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling provideOrderDigitalCodes' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.provideOrderDigitalCodes, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling provideOrderDigitalCodes' + ); + } + + // verify the required parameter 'provide_order_digital_codes_request' is set + if ($provide_order_digital_codes_request === null || (is_array($provide_order_digital_codes_request) && count($provide_order_digital_codes_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $provide_order_digital_codes_request when calling provideOrderDigitalCodes' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/deliverDigitalGoods'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($provide_order_digital_codes_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($provide_order_digital_codes_request)); + } else { + $httpBody = $provide_order_digital_codes_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation provideOrderItemIdentifiers + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function provideOrderItemIdentifiers($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers'][0]) + { + list($response) = $this->provideOrderItemIdentifiersWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + return $response; + } + + /** + * Operation provideOrderItemIdentifiersWithHttpInfo + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function provideOrderItemIdentifiersWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers'][0]) + { + $request = $this->provideOrderItemIdentifiersRequest($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation provideOrderItemIdentifiersAsync + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderItemIdentifiersAsync($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers'][0]) + { + return $this->provideOrderItemIdentifiersAsyncWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation provideOrderItemIdentifiersAsyncWithHttpInfo + * + * Передача кодов маркировки единиц товара + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function provideOrderItemIdentifiersAsyncWithHttpInfo($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers'][0]) + { + $returnType = '\OpenAPI\Client\Model\ProvideOrderItemIdentifiersResponse'; + $request = $this->provideOrderItemIdentifiersRequest($campaign_id, $order_id, $provide_order_item_identifiers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'provideOrderItemIdentifiers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\ProvideOrderItemIdentifiersRequest $provide_order_item_identifiers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['provideOrderItemIdentifiers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function provideOrderItemIdentifiersRequest($campaign_id, $order_id, $provide_order_item_identifiers_request, string $contentType = self::contentTypes['provideOrderItemIdentifiers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling provideOrderItemIdentifiers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.provideOrderItemIdentifiers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling provideOrderItemIdentifiers' + ); + } + + // verify the required parameter 'provide_order_item_identifiers_request' is set + if ($provide_order_item_identifiers_request === null || (is_array($provide_order_item_identifiers_request) && count($provide_order_item_identifiers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $provide_order_item_identifiers_request when calling provideOrderItemIdentifiers' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/identifiers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($provide_order_item_identifiers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($provide_order_item_identifiers_request)); + } else { + $httpBody = $provide_order_item_identifiers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderBoxLayout + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SetOrderBoxLayoutResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderBoxLayout($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout'][0]) + { + list($response) = $this->setOrderBoxLayoutWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + return $response; + } + + /** + * Operation setOrderBoxLayoutWithHttpInfo + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SetOrderBoxLayoutResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderBoxLayoutWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout'][0]) + { + $request = $this->setOrderBoxLayoutRequest($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SetOrderBoxLayoutResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SetOrderBoxLayoutResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderBoxLayoutAsync + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderBoxLayoutAsync($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout'][0]) + { + return $this->setOrderBoxLayoutAsyncWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderBoxLayoutAsyncWithHttpInfo + * + * Подготовка заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderBoxLayoutAsyncWithHttpInfo($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout'][0]) + { + $returnType = '\OpenAPI\Client\Model\SetOrderBoxLayoutResponse'; + $request = $this->setOrderBoxLayoutRequest($campaign_id, $order_id, $set_order_box_layout_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderBoxLayout' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\SetOrderBoxLayoutRequest $set_order_box_layout_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderBoxLayout'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderBoxLayoutRequest($campaign_id, $order_id, $set_order_box_layout_request, string $contentType = self::contentTypes['setOrderBoxLayout'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderBoxLayout' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.setOrderBoxLayout, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderBoxLayout' + ); + } + + // verify the required parameter 'set_order_box_layout_request' is set + if ($set_order_box_layout_request === null || (is_array($set_order_box_layout_request) && count($set_order_box_layout_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_box_layout_request when calling setOrderBoxLayout' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/boxes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_box_layout_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_box_layout_request)); + } else { + $httpBody = $set_order_box_layout_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setOrderShipmentBoxes + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SetOrderShipmentBoxesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setOrderShipmentBoxes($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes'][0]) + { + list($response) = $this->setOrderShipmentBoxesWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + return $response; + } + + /** + * Operation setOrderShipmentBoxesWithHttpInfo + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SetOrderShipmentBoxesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setOrderShipmentBoxesWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes'][0]) + { + $request = $this->setOrderShipmentBoxesRequest($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setOrderShipmentBoxesAsync + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderShipmentBoxesAsync($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes'][0]) + { + return $this->setOrderShipmentBoxesAsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setOrderShipmentBoxesAsyncWithHttpInfo + * + * Передача количества грузовых мест в заказе + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setOrderShipmentBoxesAsyncWithHttpInfo($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes'][0]) + { + $returnType = '\OpenAPI\Client\Model\SetOrderShipmentBoxesResponse'; + $request = $this->setOrderShipmentBoxesRequest($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setOrderShipmentBoxes' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $shipment_id Параметр больше не используется. Вставьте любое число — просто чтобы получился корректный URL. (required) + * @param \OpenAPI\Client\Model\SetOrderShipmentBoxesRequest $set_order_shipment_boxes_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setOrderShipmentBoxes'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setOrderShipmentBoxesRequest($campaign_id, $order_id, $shipment_id, $set_order_shipment_boxes_request, string $contentType = self::contentTypes['setOrderShipmentBoxes'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setOrderShipmentBoxes' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.setOrderShipmentBoxes, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setOrderShipmentBoxes' + ); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling setOrderShipmentBoxes' + ); + } + + // verify the required parameter 'set_order_shipment_boxes_request' is set + if ($set_order_shipment_boxes_request === null || (is_array($set_order_shipment_boxes_request) && count($set_order_shipment_boxes_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_order_shipment_boxes_request when calling setOrderShipmentBoxes' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_order_shipment_boxes_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_order_shipment_boxes_request)); + } else { + $httpBody = $set_order_shipment_boxes_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderItems + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return void + */ + public function updateOrderItems($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems'][0]) + { + $this->updateOrderItemsWithHttpInfo($campaign_id, $order_id, $update_order_item_request, $contentType); + } + + /** + * Operation updateOrderItemsWithHttpInfo + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderItemsWithHttpInfo($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems'][0]) + { + $request = $this->updateOrderItemsRequest($campaign_id, $order_id, $update_order_item_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderItemsAsync + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderItemsAsync($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems'][0]) + { + return $this->updateOrderItemsAsyncWithHttpInfo($campaign_id, $order_id, $update_order_item_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderItemsAsyncWithHttpInfo + * + * Удаление товара из заказа или уменьшение числа единиц + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderItemsAsyncWithHttpInfo($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems'][0]) + { + $returnType = ''; + $request = $this->updateOrderItemsRequest($campaign_id, $order_id, $update_order_item_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderItems' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderItemRequest $update_order_item_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderItems'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderItemsRequest($campaign_id, $order_id, $update_order_item_request, string $contentType = self::contentTypes['updateOrderItems'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderItems' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.updateOrderItems, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderItems' + ); + } + + // verify the required parameter 'update_order_item_request' is set + if ($update_order_item_request === null || (is_array($update_order_item_request) && count($update_order_item_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_item_request when calling updateOrderItems' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/items'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_item_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_item_request)); + } else { + $httpBody = $update_order_item_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStatus + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOrderStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStatus($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus'][0]) + { + list($response) = $this->updateOrderStatusWithHttpInfo($campaign_id, $order_id, $update_order_status_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStatusWithHttpInfo + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOrderStatusResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStatusWithHttpInfo($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus'][0]) + { + $request = $this->updateOrderStatusRequest($campaign_id, $order_id, $update_order_status_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOrderStatusResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOrderStatusResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOrderStatusResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOrderStatusResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStatusAsync + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatusAsync($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus'][0]) + { + return $this->updateOrderStatusAsyncWithHttpInfo($campaign_id, $order_id, $update_order_status_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStatusAsyncWithHttpInfo + * + * Изменение статуса одного заказа + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatusAsyncWithHttpInfo($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusResponse'; + $request = $this->updateOrderStatusRequest($campaign_id, $order_id, $update_order_status_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStatus' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusRequest $update_order_status_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatus'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStatusRequest($campaign_id, $order_id, $update_order_status_request, string $contentType = self::contentTypes['updateOrderStatus'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStatus' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.updateOrderStatus, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling updateOrderStatus' + ); + } + + // verify the required parameter 'update_order_status_request' is set + if ($update_order_status_request === null || (is_array($update_order_status_request) && count($update_order_status_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_status_request when calling updateOrderStatus' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/status'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_status_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_status_request)); + } else { + $httpBody = $update_order_status_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOrderStatuses + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdateOrderStatusesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOrderStatuses($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses'][0]) + { + list($response) = $this->updateOrderStatusesWithHttpInfo($campaign_id, $update_order_statuses_request, $contentType); + return $response; + } + + /** + * Operation updateOrderStatusesWithHttpInfo + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdateOrderStatusesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOrderStatusesWithHttpInfo($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses'][0]) + { + $request = $this->updateOrderStatusesRequest($campaign_id, $update_order_statuses_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdateOrderStatusesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdateOrderStatusesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdateOrderStatusesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdateOrderStatusesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOrderStatusesAsync + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatusesAsync($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses'][0]) + { + return $this->updateOrderStatusesAsyncWithHttpInfo($campaign_id, $update_order_statuses_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOrderStatusesAsyncWithHttpInfo + * + * Изменение статусов нескольких заказов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOrderStatusesAsyncWithHttpInfo($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdateOrderStatusesResponse'; + $request = $this->updateOrderStatusesRequest($campaign_id, $update_order_statuses_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOrderStatuses' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOrderStatusesRequest $update_order_statuses_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOrderStatuses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOrderStatusesRequest($campaign_id, $update_order_statuses_request, string $contentType = self::contentTypes['updateOrderStatuses'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOrderStatuses' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersApi.updateOrderStatuses, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_order_statuses_request' is set + if ($update_order_statuses_request === null || (is_array($update_order_statuses_request) && count($update_order_statuses_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_order_statuses_request when calling updateOrderStatuses' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/status-update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_order_statuses_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_order_statuses_request)); + } else { + $httpBody = $update_order_statuses_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OrdersStatsApi.php b/erp24/lib/yandex_market_api/Api/OrdersStatsApi.php new file mode 100644 index 00000000..1c0020d1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OrdersStatsApi.php @@ -0,0 +1,716 @@ + [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getOrdersStats + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOrdersStats($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats'][0]) + { + list($response) = $this->getOrdersStatsWithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + return $response; + } + + /** + * Operation getOrdersStatsWithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOrdersStatsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOrdersStatsWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats'][0]) + { + $request = $this->getOrdersStatsRequest($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOrdersStatsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOrdersStatsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOrdersStatsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOrdersStatsAsync + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStatsAsync($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats'][0]) + { + return $this->getOrdersStatsAsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOrdersStatsAsyncWithHttpInfo + * + * Детальная информация по заказам + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrdersStatsAsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOrdersStatsResponse'; + $request = $this->getOrdersStatsRequest($campaign_id, $page_token, $limit, $get_orders_stats_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrdersStats' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetOrdersStatsRequest $get_orders_stats_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrdersStats'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOrdersStatsRequest($campaign_id, $page_token = null, $limit = null, $get_orders_stats_request = null, string $contentType = self::contentTypes['getOrdersStats'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOrdersStats' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OrdersStatsApi.getOrdersStats, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/stats/orders'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_orders_stats_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_orders_stats_request)); + } else { + $httpBody = $get_orders_stats_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OutletLicensesApi.php b/erp24/lib/yandex_market_api/Api/OutletLicensesApi.php new file mode 100644 index 00000000..681939b3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OutletLicensesApi.php @@ -0,0 +1,1818 @@ + [ + 'application/json', + ], + 'getOutletLicenses' => [ + 'application/json', + ], + 'updateOutletLicenses' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation deleteOutletLicenses + * + * Удаление лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOutletLicenses($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses'][0]) + { + list($response) = $this->deleteOutletLicensesWithHttpInfo($campaign_id, $ids, $contentType); + return $response; + } + + /** + * Operation deleteOutletLicensesWithHttpInfo + * + * Удаление лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOutletLicensesWithHttpInfo($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses'][0]) + { + $request = $this->deleteOutletLicensesRequest($campaign_id, $ids, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOutletLicensesAsync + * + * Удаление лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOutletLicensesAsync($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses'][0]) + { + return $this->deleteOutletLicensesAsyncWithHttpInfo($campaign_id, $ids, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOutletLicensesAsyncWithHttpInfo + * + * Удаление лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOutletLicensesAsyncWithHttpInfo($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteOutletLicensesRequest($campaign_id, $ids, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOutletLicenses' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $ids Список идентификаторов лицензий для удаления. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOutletLicensesRequest($campaign_id, $ids, string $contentType = self::contentTypes['deleteOutletLicenses'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteOutletLicenses' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OutletLicensesApi.deleteOutletLicenses, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'ids' is set + if ($ids === null || (is_array($ids) && count($ids) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $ids when calling deleteOutletLicenses' + ); + } + if (count($ids) < 1) { + throw new \InvalidArgumentException('invalid value for "$ids" when calling OutletLicensesApi.deleteOutletLicenses, number of items must be greater than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/licenses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $ids, + 'ids', // param base name + 'array', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOutletLicenses + * + * Информация о лицензиях для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOutletLicensesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOutletLicenses($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses'][0]) + { + list($response) = $this->getOutletLicensesWithHttpInfo($campaign_id, $outlet_ids, $ids, $contentType); + return $response; + } + + /** + * Operation getOutletLicensesWithHttpInfo + * + * Информация о лицензиях для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOutletLicensesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOutletLicensesWithHttpInfo($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses'][0]) + { + $request = $this->getOutletLicensesRequest($campaign_id, $outlet_ids, $ids, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOutletLicensesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOutletLicensesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOutletLicensesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOutletLicensesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOutletLicensesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOutletLicensesAsync + * + * Информация о лицензиях для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutletLicensesAsync($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses'][0]) + { + return $this->getOutletLicensesAsyncWithHttpInfo($campaign_id, $outlet_ids, $ids, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOutletLicensesAsyncWithHttpInfo + * + * Информация о лицензиях для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutletLicensesAsyncWithHttpInfo($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOutletLicensesResponse'; + $request = $this->getOutletLicensesRequest($campaign_id, $outlet_ids, $ids, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOutletLicenses' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int[] $outlet_ids Список идентификаторов точек продаж, для которых нужно получить информацию о лицензиях. Идентификаторы указываются через запятую. В запросе должен быть либо параметр `outletIds`, либо параметр `ids`. Запрос с обоими параметрами или без них приведет к ошибке. (optional) + * @param int[] $ids Список идентификаторов лицензий. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOutletLicensesRequest($campaign_id, $outlet_ids = null, $ids = null, string $contentType = self::contentTypes['getOutletLicenses'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOutletLicenses' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OutletLicensesApi.getOutletLicenses, must be bigger than or equal to 1.'); + } + + if ($outlet_ids !== null && count($outlet_ids) > 500) { + throw new \InvalidArgumentException('invalid value for "$outlet_ids" when calling OutletLicensesApi.getOutletLicenses, number of items must be less than or equal to 500.'); + } + if ($outlet_ids !== null && count($outlet_ids) < 1) { + throw new \InvalidArgumentException('invalid value for "$outlet_ids" when calling OutletLicensesApi.getOutletLicenses, number of items must be greater than or equal to 1.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/outlets/licenses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $outlet_ids, + 'outletIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $ids, + 'ids', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOutletLicenses + * + * Создание и изменение лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOutletLicenses($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses'][0]) + { + list($response) = $this->updateOutletLicensesWithHttpInfo($campaign_id, $update_outlet_license_request, $contentType); + return $response; + } + + /** + * Operation updateOutletLicensesWithHttpInfo + * + * Создание и изменение лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOutletLicensesWithHttpInfo($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses'][0]) + { + $request = $this->updateOutletLicensesRequest($campaign_id, $update_outlet_license_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOutletLicensesAsync + * + * Создание и изменение лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOutletLicensesAsync($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses'][0]) + { + return $this->updateOutletLicensesAsyncWithHttpInfo($campaign_id, $update_outlet_license_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOutletLicensesAsyncWithHttpInfo + * + * Создание и изменение лицензий для точек продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOutletLicensesAsyncWithHttpInfo($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOutletLicensesRequest($campaign_id, $update_outlet_license_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOutletLicenses' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateOutletLicenseRequest $update_outlet_license_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutletLicenses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOutletLicensesRequest($campaign_id, $update_outlet_license_request, string $contentType = self::contentTypes['updateOutletLicenses'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOutletLicenses' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OutletLicensesApi.updateOutletLicenses, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_outlet_license_request' is set + if ($update_outlet_license_request === null || (is_array($update_outlet_license_request) && count($update_outlet_license_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_outlet_license_request when calling updateOutletLicenses' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/licenses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_outlet_license_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_outlet_license_request)); + } else { + $httpBody = $update_outlet_license_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/OutletsApi.php b/erp24/lib/yandex_market_api/Api/OutletsApi.php new file mode 100644 index 00000000..5e3ad953 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/OutletsApi.php @@ -0,0 +1,2972 @@ + [ + 'application/json', + ], + 'deleteOutlet' => [ + 'application/json', + ], + 'getOutlet' => [ + 'application/json', + ], + 'getOutlets' => [ + 'application/json', + ], + 'updateOutlet' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation createOutlet + * + * Создание точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CreateOutletResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function createOutlet($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet'][0]) + { + list($response) = $this->createOutletWithHttpInfo($campaign_id, $change_outlet_request, $contentType); + return $response; + } + + /** + * Operation createOutletWithHttpInfo + * + * Создание точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CreateOutletResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function createOutletWithHttpInfo($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet'][0]) + { + $request = $this->createOutletRequest($campaign_id, $change_outlet_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CreateOutletResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CreateOutletResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CreateOutletResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CreateOutletResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CreateOutletResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createOutletAsync + * + * Создание точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createOutletAsync($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet'][0]) + { + return $this->createOutletAsyncWithHttpInfo($campaign_id, $change_outlet_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createOutletAsyncWithHttpInfo + * + * Создание точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createOutletAsyncWithHttpInfo($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet'][0]) + { + $returnType = '\OpenAPI\Client\Model\CreateOutletResponse'; + $request = $this->createOutletRequest($campaign_id, $change_outlet_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createOutlet' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function createOutletRequest($campaign_id, $change_outlet_request, string $contentType = self::contentTypes['createOutlet'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling createOutlet' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OutletsApi.createOutlet, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'change_outlet_request' is set + if ($change_outlet_request === null || (is_array($change_outlet_request) && count($change_outlet_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $change_outlet_request when calling createOutlet' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($change_outlet_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($change_outlet_request)); + } else { + $httpBody = $change_outlet_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteOutlet + * + * Удаление точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deleteOutlet($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet'][0]) + { + list($response) = $this->deleteOutletWithHttpInfo($campaign_id, $outlet_id, $contentType); + return $response; + } + + /** + * Operation deleteOutletWithHttpInfo + * + * Удаление точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deleteOutletWithHttpInfo($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet'][0]) + { + $request = $this->deleteOutletRequest($campaign_id, $outlet_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deleteOutletAsync + * + * Удаление точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOutletAsync($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet'][0]) + { + return $this->deleteOutletAsyncWithHttpInfo($campaign_id, $outlet_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteOutletAsyncWithHttpInfo + * + * Удаление точки продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOutletAsyncWithHttpInfo($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->deleteOutletRequest($campaign_id, $outlet_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOutlet' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deleteOutletRequest($campaign_id, $outlet_id, string $contentType = self::contentTypes['deleteOutlet'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling deleteOutlet' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OutletsApi.deleteOutlet, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'outlet_id' is set + if ($outlet_id === null || (is_array($outlet_id) && count($outlet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $outlet_id when calling deleteOutlet' + ); + } + if ($outlet_id < 1) { + throw new \InvalidArgumentException('invalid value for "$outlet_id" when calling OutletsApi.deleteOutlet, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/{outletId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($outlet_id !== null) { + $resourcePath = str_replace( + '{' . 'outletId' . '}', + ObjectSerializer::toPathValue($outlet_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'DELETE', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOutlet + * + * Информация об одной точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOutletResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOutlet($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet'][0]) + { + list($response) = $this->getOutletWithHttpInfo($campaign_id, $outlet_id, $contentType); + return $response; + } + + /** + * Operation getOutletWithHttpInfo + * + * Информация об одной точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOutletResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOutletWithHttpInfo($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet'][0]) + { + $request = $this->getOutletRequest($campaign_id, $outlet_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOutletResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOutletResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOutletResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOutletResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOutletResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOutletAsync + * + * Информация об одной точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutletAsync($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet'][0]) + { + return $this->getOutletAsyncWithHttpInfo($campaign_id, $outlet_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOutletAsyncWithHttpInfo + * + * Информация об одной точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutletAsyncWithHttpInfo($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOutletResponse'; + $request = $this->getOutletRequest($campaign_id, $outlet_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOutlet' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOutletRequest($campaign_id, $outlet_id, string $contentType = self::contentTypes['getOutlet'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOutlet' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OutletsApi.getOutlet, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'outlet_id' is set + if ($outlet_id === null || (is_array($outlet_id) && count($outlet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $outlet_id when calling getOutlet' + ); + } + if ($outlet_id < 1) { + throw new \InvalidArgumentException('invalid value for "$outlet_id" when calling OutletsApi.getOutlet, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/{outletId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($outlet_id !== null) { + $resourcePath = str_replace( + '{' . 'outletId' . '}', + ObjectSerializer::toPathValue($outlet_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getOutlets + * + * Информация о нескольких точках продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetOutletsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getOutlets($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets'][0]) + { + list($response) = $this->getOutletsWithHttpInfo($campaign_id, $page_token, $region_id, $shop_outlet_code, $region_id2, $contentType); + return $response; + } + + /** + * Operation getOutletsWithHttpInfo + * + * Информация о нескольких точках продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetOutletsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getOutletsWithHttpInfo($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets'][0]) + { + $request = $this->getOutletsRequest($campaign_id, $page_token, $region_id, $shop_outlet_code, $region_id2, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetOutletsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetOutletsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetOutletsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetOutletsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetOutletsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getOutletsAsync + * + * Информация о нескольких точках продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutletsAsync($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets'][0]) + { + return $this->getOutletsAsyncWithHttpInfo($campaign_id, $page_token, $region_id, $shop_outlet_code, $region_id2, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getOutletsAsyncWithHttpInfo + * + * Информация о нескольких точках продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOutletsAsyncWithHttpInfo($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetOutletsResponse'; + $request = $this->getOutletsRequest($campaign_id, $page_token, $region_id, $shop_outlet_code, $region_id2, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOutlets' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $region_id Идентификатор региона. Если задать идентификатор родительского региона любого уровня, в выходных данных будут отображены точки продаж всех дочерних регионов. Идентификатор региона можно получить c помощью метода [GET regions](../../reference/regions/searchRegionsByName.md). (optional) + * @param string $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. (optional) + * @param int $region_id2 {% note warning \"\" %} Этот параметр устарел. Для указания региона используйте `region_id`. {% endnote %} (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOutlets'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getOutletsRequest($campaign_id, $page_token = null, $region_id = null, $shop_outlet_code = null, $region_id2 = null, string $contentType = self::contentTypes['getOutlets'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getOutlets' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OutletsApi.getOutlets, must be bigger than or equal to 1.'); + } + + + + + + + $resourcePath = '/campaigns/{campaignId}/outlets'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id, + 'region_id', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $shop_outlet_code, + 'shop_outlet_code', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $region_id2, + 'regionId', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateOutlet + * + * Изменение информации о точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateOutlet($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet'][0]) + { + list($response) = $this->updateOutletWithHttpInfo($campaign_id, $outlet_id, $change_outlet_request, $contentType); + return $response; + } + + /** + * Operation updateOutletWithHttpInfo + * + * Изменение информации о точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateOutletWithHttpInfo($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet'][0]) + { + $request = $this->updateOutletRequest($campaign_id, $outlet_id, $change_outlet_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateOutletAsync + * + * Изменение информации о точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOutletAsync($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet'][0]) + { + return $this->updateOutletAsyncWithHttpInfo($campaign_id, $outlet_id, $change_outlet_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateOutletAsyncWithHttpInfo + * + * Изменение информации о точке продаж + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateOutletAsyncWithHttpInfo($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateOutletRequest($campaign_id, $outlet_id, $change_outlet_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateOutlet' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $outlet_id Идентификатор точки продаж. (required) + * @param \OpenAPI\Client\Model\ChangeOutletRequest $change_outlet_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateOutlet'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateOutletRequest($campaign_id, $outlet_id, $change_outlet_request, string $contentType = self::contentTypes['updateOutlet'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateOutlet' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling OutletsApi.updateOutlet, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'outlet_id' is set + if ($outlet_id === null || (is_array($outlet_id) && count($outlet_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $outlet_id when calling updateOutlet' + ); + } + if ($outlet_id < 1) { + throw new \InvalidArgumentException('invalid value for "$outlet_id" when calling OutletsApi.updateOutlet, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'change_outlet_request' is set + if ($change_outlet_request === null || (is_array($change_outlet_request) && count($change_outlet_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $change_outlet_request when calling updateOutlet' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/outlets/{outletId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($outlet_id !== null) { + $resourcePath = str_replace( + '{' . 'outletId' . '}', + ObjectSerializer::toPathValue($outlet_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($change_outlet_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($change_outlet_request)); + } else { + $httpBody = $change_outlet_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/PriceQuarantineApi.php b/erp24/lib/yandex_market_api/Api/PriceQuarantineApi.php new file mode 100644 index 00000000..1c7d20f6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/PriceQuarantineApi.php @@ -0,0 +1,2478 @@ + [ + 'application/json', + ], + 'confirmCampaignPrices' => [ + 'application/json', + ], + 'getBusinessQuarantineOffers' => [ + 'application/json', + ], + 'getCampaignQuarantineOffers' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation confirmBusinessPrices + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmBusinessPrices($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices'][0]) + { + list($response) = $this->confirmBusinessPricesWithHttpInfo($business_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmBusinessPricesWithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmBusinessPricesWithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices'][0]) + { + $request = $this->confirmBusinessPricesRequest($business_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmBusinessPricesAsync + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPricesAsync($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices'][0]) + { + return $this->confirmBusinessPricesAsyncWithHttpInfo($business_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmBusinessPricesAsyncWithHttpInfo + * + * Удаление товара из карантина по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmBusinessPricesAsyncWithHttpInfo($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmBusinessPricesRequest($business_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmBusinessPrices' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmBusinessPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmBusinessPricesRequest($business_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmBusinessPrices'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling confirmBusinessPrices' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling PriceQuarantineApi.confirmBusinessPrices, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmBusinessPrices' + ); + } + + + $resourcePath = '/businesses/{businessId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation confirmCampaignPrices + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmCampaignPrices($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices'][0]) + { + list($response) = $this->confirmCampaignPricesWithHttpInfo($campaign_id, $confirm_prices_request, $contentType); + return $response; + } + + /** + * Operation confirmCampaignPricesWithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmCampaignPricesWithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices'][0]) + { + $request = $this->confirmCampaignPricesRequest($campaign_id, $confirm_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmCampaignPricesAsync + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPricesAsync($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices'][0]) + { + return $this->confirmCampaignPricesAsyncWithHttpInfo($campaign_id, $confirm_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmCampaignPricesAsyncWithHttpInfo + * + * Удаление товара из карантина по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmCampaignPricesAsyncWithHttpInfo($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmCampaignPricesRequest($campaign_id, $confirm_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmCampaignPrices' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\ConfirmPricesRequest $confirm_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmCampaignPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmCampaignPricesRequest($campaign_id, $confirm_prices_request, string $contentType = self::contentTypes['confirmCampaignPrices'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling confirmCampaignPrices' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling PriceQuarantineApi.confirmCampaignPrices, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'confirm_prices_request' is set + if ($confirm_prices_request === null || (is_array($confirm_prices_request) && count($confirm_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $confirm_prices_request when calling confirmCampaignPrices' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_prices_request)); + } else { + $httpBody = $confirm_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getBusinessQuarantineOffers + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getBusinessQuarantineOffers($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers'][0]) + { + list($response) = $this->getBusinessQuarantineOffersWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getBusinessQuarantineOffersWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getBusinessQuarantineOffersWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers'][0]) + { + $request = $this->getBusinessQuarantineOffersRequest($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getBusinessQuarantineOffersAsync + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffersAsync($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers'][0]) + { + return $this->getBusinessQuarantineOffersAsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getBusinessQuarantineOffersAsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в кабинете + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getBusinessQuarantineOffersAsyncWithHttpInfo($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getBusinessQuarantineOffersRequest($business_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getBusinessQuarantineOffers' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getBusinessQuarantineOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getBusinessQuarantineOffersRequest($business_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getBusinessQuarantineOffers'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getBusinessQuarantineOffers' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling PriceQuarantineApi.getBusinessQuarantineOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getBusinessQuarantineOffers' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getCampaignQuarantineOffers + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getCampaignQuarantineOffers($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers'][0]) + { + list($response) = $this->getCampaignQuarantineOffersWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getCampaignQuarantineOffersWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQuarantineOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getCampaignQuarantineOffersWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers'][0]) + { + $request = $this->getCampaignQuarantineOffersRequest($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQuarantineOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQuarantineOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQuarantineOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getCampaignQuarantineOffersAsync + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffersAsync($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers'][0]) + { + return $this->getCampaignQuarantineOffersAsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getCampaignQuarantineOffersAsyncWithHttpInfo + * + * Список товаров, находящихся в карантине по цене в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getCampaignQuarantineOffersAsyncWithHttpInfo($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQuarantineOffersResponse'; + $request = $this->getCampaignQuarantineOffersRequest($campaign_id, $get_quarantine_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getCampaignQuarantineOffers' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQuarantineOffersRequest $get_quarantine_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getCampaignQuarantineOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getCampaignQuarantineOffersRequest($campaign_id, $get_quarantine_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getCampaignQuarantineOffers'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getCampaignQuarantineOffers' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling PriceQuarantineApi.getCampaignQuarantineOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quarantine_offers_request' is set + if ($get_quarantine_offers_request === null || (is_array($get_quarantine_offers_request) && count($get_quarantine_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quarantine_offers_request when calling getCampaignQuarantineOffers' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/price-quarantine'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quarantine_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quarantine_offers_request)); + } else { + $httpBody = $get_quarantine_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/PricesApi.php b/erp24/lib/yandex_market_api/Api/PricesApi.php new file mode 100644 index 00000000..7121a4b5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/PricesApi.php @@ -0,0 +1,3030 @@ + [ + 'application/json', + ], + 'getPricesByOfferIds' => [ + 'application/json', + ], + 'getSuggestedPrices' => [ + 'application/json', + ], + 'updateBusinessPrices' => [ + 'application/json', + ], + 'updatePrices' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getPrices + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getPrices($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices'][0]) + { + list($response) = $this->getPricesWithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType); + return $response; + } + + /** + * Operation getPricesWithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getPricesWithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices'][0]) + { + $request = $this->getPricesRequest($campaign_id, $page_token, $limit, $archived, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPricesAsync + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPricesAsync($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices'][0]) + { + return $this->getPricesAsyncWithHttpInfo($campaign_id, $page_token, $limit, $archived, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPricesAsyncWithHttpInfo + * + * Список цен + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getPricesAsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesResponse'; + $request = $this->getPricesRequest($campaign_id, $page_token, $limit, $archived, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPrices' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param bool $archived Фильтр по нахождению в архиве. (optional, default to false) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getPricesRequest($campaign_id, $page_token = null, $limit = null, $archived = false, string $contentType = self::contentTypes['getPrices'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPrices' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling PricesApi.getPrices, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $archived, + 'archived', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPricesByOfferIds + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPricesByOfferIds($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds'][0]) + { + list($response) = $this->getPricesByOfferIdsWithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + return $response; + } + + /** + * Operation getPricesByOfferIdsWithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPricesByOfferIdsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPricesByOfferIdsWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds'][0]) + { + $request = $this->getPricesByOfferIdsRequest($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPricesByOfferIdsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPricesByOfferIdsAsync + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIdsAsync($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds'][0]) + { + return $this->getPricesByOfferIdsAsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPricesByOfferIdsAsyncWithHttpInfo + * + * Просмотр цен на указанные товары в магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPricesByOfferIdsAsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPricesByOfferIdsResponse'; + $request = $this->getPricesByOfferIdsRequest($campaign_id, $page_token, $limit, $get_prices_by_offer_ids_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPricesByOfferIds' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetPricesByOfferIdsRequest $get_prices_by_offer_ids_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPricesByOfferIds'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPricesByOfferIdsRequest($campaign_id, $page_token = null, $limit = null, $get_prices_by_offer_ids_request = null, string $contentType = self::contentTypes['getPricesByOfferIds'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getPricesByOfferIds' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling PricesApi.getPricesByOfferIds, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offer-prices'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_prices_by_offer_ids_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_prices_by_offer_ids_request)); + } else { + $httpBody = $get_prices_by_offer_ids_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getSuggestedPrices + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + * @deprecated + */ + public function getSuggestedPrices($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices'][0]) + { + list($response) = $this->getSuggestedPricesWithHttpInfo($campaign_id, $suggest_prices_request, $contentType); + return $response; + } + + /** + * Operation getSuggestedPricesWithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SuggestPricesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + * @deprecated + */ + public function getSuggestedPricesWithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices'][0]) + { + $request = $this->getSuggestedPricesRequest($campaign_id, $suggest_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SuggestPricesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SuggestPricesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SuggestPricesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SuggestPricesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getSuggestedPricesAsync + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPricesAsync($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices'][0]) + { + return $this->getSuggestedPricesAsyncWithHttpInfo($campaign_id, $suggest_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getSuggestedPricesAsyncWithHttpInfo + * + * Цены для продвижения товаров + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + * @deprecated + */ + public function getSuggestedPricesAsyncWithHttpInfo($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices'][0]) + { + $returnType = '\OpenAPI\Client\Model\SuggestPricesResponse'; + $request = $this->getSuggestedPricesRequest($campaign_id, $suggest_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getSuggestedPrices' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SuggestPricesRequest $suggest_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getSuggestedPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + * @deprecated + */ + public function getSuggestedPricesRequest($campaign_id, $suggest_prices_request, string $contentType = self::contentTypes['getSuggestedPrices'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getSuggestedPrices' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling PricesApi.getSuggestedPrices, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'suggest_prices_request' is set + if ($suggest_prices_request === null || (is_array($suggest_prices_request) && count($suggest_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $suggest_prices_request when calling getSuggestedPrices' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/suggestions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($suggest_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($suggest_prices_request)); + } else { + $httpBody = $suggest_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateBusinessPrices + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateBusinessPrices($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices'][0]) + { + list($response) = $this->updateBusinessPricesWithHttpInfo($business_id, $update_business_prices_request, $contentType); + return $response; + } + + /** + * Operation updateBusinessPricesWithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateBusinessPricesWithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices'][0]) + { + $request = $this->updateBusinessPricesRequest($business_id, $update_business_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateBusinessPricesAsync + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPricesAsync($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices'][0]) + { + return $this->updateBusinessPricesAsyncWithHttpInfo($business_id, $update_business_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateBusinessPricesAsyncWithHttpInfo + * + * Установка цен на товары во всех магазинах + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateBusinessPricesAsyncWithHttpInfo($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateBusinessPricesRequest($business_id, $update_business_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateBusinessPrices' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateBusinessPricesRequest $update_business_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateBusinessPrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateBusinessPricesRequest($business_id, $update_business_prices_request, string $contentType = self::contentTypes['updateBusinessPrices'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updateBusinessPrices' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling PricesApi.updateBusinessPrices, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_business_prices_request' is set + if ($update_business_prices_request === null || (is_array($update_business_prices_request) && count($update_business_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_business_prices_request when calling updateBusinessPrices' + ); + } + + + $resourcePath = '/businesses/{businessId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_business_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_business_prices_request)); + } else { + $httpBody = $update_business_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePrices + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePrices($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices'][0]) + { + list($response) = $this->updatePricesWithHttpInfo($campaign_id, $update_prices_request, $contentType); + return $response; + } + + /** + * Operation updatePricesWithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiLockedErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePricesWithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices'][0]) + { + $request = $this->updatePricesRequest($campaign_id, $update_prices_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 423: + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLockedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLockedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 423: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLockedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePricesAsync + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePricesAsync($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices'][0]) + { + return $this->updatePricesAsyncWithHttpInfo($campaign_id, $update_prices_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePricesAsyncWithHttpInfo + * + * Установка цен на товары в конкретном магазине + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePricesAsyncWithHttpInfo($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updatePricesRequest($campaign_id, $update_prices_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePrices' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePricesRequest $update_prices_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePrices'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePricesRequest($campaign_id, $update_prices_request, string $contentType = self::contentTypes['updatePrices'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updatePrices' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling PricesApi.updatePrices, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_prices_request' is set + if ($update_prices_request === null || (is_array($update_prices_request) && count($update_prices_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_prices_request when calling updatePrices' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offer-prices/updates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_prices_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_prices_request)); + } else { + $httpBody = $update_prices_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/PromosApi.php b/erp24/lib/yandex_market_api/Api/PromosApi.php new file mode 100644 index 00000000..ee8fd668 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/PromosApi.php @@ -0,0 +1,2372 @@ + [ + 'application/json', + ], + 'getPromoOffers' => [ + 'application/json', + ], + 'getPromos' => [ + 'application/json', + ], + 'updatePromoOffers' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation deletePromoOffers + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function deletePromoOffers($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers'][0]) + { + list($response) = $this->deletePromoOffersWithHttpInfo($business_id, $delete_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation deletePromoOffersWithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\DeletePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function deletePromoOffersWithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers'][0]) + { + $request = $this->deletePromoOffersRequest($business_id, $delete_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\DeletePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\DeletePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\DeletePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation deletePromoOffersAsync + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffersAsync($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers'][0]) + { + return $this->deletePromoOffersAsyncWithHttpInfo($business_id, $delete_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deletePromoOffersAsyncWithHttpInfo + * + * Удаление товаров из акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePromoOffersAsyncWithHttpInfo($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\DeletePromoOffersResponse'; + $request = $this->deletePromoOffersRequest($business_id, $delete_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePromoOffers' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\DeletePromoOffersRequest $delete_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function deletePromoOffersRequest($business_id, $delete_promo_offers_request, string $contentType = self::contentTypes['deletePromoOffers'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling deletePromoOffers' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling PromosApi.deletePromoOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'delete_promo_offers_request' is set + if ($delete_promo_offers_request === null || (is_array($delete_promo_offers_request) && count($delete_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $delete_promo_offers_request when calling deletePromoOffers' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/delete'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($delete_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($delete_promo_offers_request)); + } else { + $httpBody = $delete_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromoOffers + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromoOffers($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers'][0]) + { + list($response) = $this->getPromoOffersWithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation getPromoOffersWithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromoOffersWithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers'][0]) + { + $request = $this->getPromoOffersRequest($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromoOffersAsync + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffersAsync($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers'][0]) + { + return $this->getPromoOffersAsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromoOffersAsyncWithHttpInfo + * + * Получение списка товаров, которые участвуют или могут участвовать в акции + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromoOffersAsyncWithHttpInfo($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromoOffersResponse'; + $request = $this->getPromoOffersRequest($business_id, $get_promo_offers_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromoOffers' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromoOffersRequest $get_promo_offers_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromoOffersRequest($business_id, $get_promo_offers_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['getPromoOffers'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromoOffers' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling PromosApi.getPromoOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_promo_offers_request' is set + if ($get_promo_offers_request === null || (is_array($get_promo_offers_request) && count($get_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_promo_offers_request when calling getPromoOffers' + ); + } + + + + + $resourcePath = '/businesses/{businessId}/promos/offers'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promo_offers_request)); + } else { + $httpBody = $get_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPromos + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getPromos($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos'][0]) + { + list($response) = $this->getPromosWithHttpInfo($business_id, $get_promos_request, $contentType); + return $response; + } + + /** + * Operation getPromosWithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetPromosResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getPromosWithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos'][0]) + { + $request = $this->getPromosRequest($business_id, $get_promos_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetPromosResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetPromosResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetPromosResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetPromosResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPromosAsync + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromosAsync($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos'][0]) + { + return $this->getPromosAsyncWithHttpInfo($business_id, $get_promos_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPromosAsyncWithHttpInfo + * + * Получение списка акций + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPromosAsyncWithHttpInfo($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetPromosResponse'; + $request = $this->getPromosRequest($business_id, $get_promos_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPromos' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetPromosRequest $get_promos_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPromos'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getPromosRequest($business_id, $get_promos_request = null, string $contentType = self::contentTypes['getPromos'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getPromos' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling PromosApi.getPromos, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/businesses/{businessId}/promos'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_promos_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_promos_request)); + } else { + $httpBody = $get_promos_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePromoOffers + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updatePromoOffers($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers'][0]) + { + list($response) = $this->updatePromoOffersWithHttpInfo($business_id, $update_promo_offers_request, $contentType); + return $response; + } + + /** + * Operation updatePromoOffersWithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\UpdatePromoOffersResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updatePromoOffersWithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers'][0]) + { + $request = $this->updatePromoOffersRequest($business_id, $update_promo_offers_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\UpdatePromoOffersResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\UpdatePromoOffersResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\UpdatePromoOffersResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updatePromoOffersAsync + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffersAsync($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers'][0]) + { + return $this->updatePromoOffersAsyncWithHttpInfo($business_id, $update_promo_offers_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePromoOffersAsyncWithHttpInfo + * + * Добавление товаров в акцию или изменение их цен + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePromoOffersAsyncWithHttpInfo($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers'][0]) + { + $returnType = '\OpenAPI\Client\Model\UpdatePromoOffersResponse'; + $request = $this->updatePromoOffersRequest($business_id, $update_promo_offers_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePromoOffers' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdatePromoOffersRequest $update_promo_offers_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePromoOffers'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updatePromoOffersRequest($business_id, $update_promo_offers_request, string $contentType = self::contentTypes['updatePromoOffers'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling updatePromoOffers' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling PromosApi.updatePromoOffers, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_promo_offers_request' is set + if ($update_promo_offers_request === null || (is_array($update_promo_offers_request) && count($update_promo_offers_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_promo_offers_request when calling updatePromoOffers' + ); + } + + + $resourcePath = '/businesses/{businessId}/promos/offers/update'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_promo_offers_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_promo_offers_request)); + } else { + $httpBody = $update_promo_offers_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/RatingsApi.php b/erp24/lib/yandex_market_api/Api/RatingsApi.php new file mode 100644 index 00000000..2f838ab6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/RatingsApi.php @@ -0,0 +1,1225 @@ + [ + 'application/json', + ], + 'getQualityRatings' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getQualityRatingDetails + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingDetailsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatingDetails($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails'][0]) + { + list($response) = $this->getQualityRatingDetailsWithHttpInfo($campaign_id, $contentType); + return $response; + } + + /** + * Operation getQualityRatingDetailsWithHttpInfo + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingDetailsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatingDetailsWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails'][0]) + { + $request = $this->getQualityRatingDetailsRequest($campaign_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingDetailsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingDetailsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatingDetailsAsync + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingDetailsAsync($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails'][0]) + { + return $this->getQualityRatingDetailsAsyncWithHttpInfo($campaign_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatingDetailsAsyncWithHttpInfo + * + * Заказы, которые повлияли на индекс качества + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingDetailsAsyncWithHttpInfo($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingDetailsResponse'; + $request = $this->getQualityRatingDetailsRequest($campaign_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatingDetails' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatingDetails'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatingDetailsRequest($campaign_id, string $contentType = self::contentTypes['getQualityRatingDetails'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getQualityRatingDetails' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling RatingsApi.getQualityRatingDetails, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/ratings/quality/details'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getQualityRatings + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getQualityRatings($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings'][0]) + { + list($response) = $this->getQualityRatingsWithHttpInfo($business_id, $get_quality_rating_request, $contentType); + return $response; + } + + /** + * Operation getQualityRatingsWithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetQualityRatingResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getQualityRatingsWithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings'][0]) + { + $request = $this->getQualityRatingsRequest($business_id, $get_quality_rating_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetQualityRatingResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetQualityRatingResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetQualityRatingResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getQualityRatingsAsync + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingsAsync($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings'][0]) + { + return $this->getQualityRatingsAsyncWithHttpInfo($business_id, $get_quality_rating_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getQualityRatingsAsyncWithHttpInfo + * + * Индекс качества магазинов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getQualityRatingsAsyncWithHttpInfo($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetQualityRatingResponse'; + $request = $this->getQualityRatingsRequest($business_id, $get_quality_rating_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getQualityRatings' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\GetQualityRatingRequest $get_quality_rating_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getQualityRatings'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getQualityRatingsRequest($business_id, $get_quality_rating_request, string $contentType = self::contentTypes['getQualityRatings'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getQualityRatings' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling RatingsApi.getQualityRatings, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'get_quality_rating_request' is set + if ($get_quality_rating_request === null || (is_array($get_quality_rating_request) && count($get_quality_rating_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $get_quality_rating_request when calling getQualityRatings' + ); + } + + + $resourcePath = '/businesses/{businessId}/ratings/quality'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_quality_rating_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_quality_rating_request)); + } else { + $httpBody = $get_quality_rating_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/RegionsApi.php b/erp24/lib/yandex_market_api/Api/RegionsApi.php new file mode 100644 index 00000000..abcfcfa5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/RegionsApi.php @@ -0,0 +1,1689 @@ + [ + 'application/json', + ], + 'searchRegionsById' => [ + 'application/json', + ], + 'searchRegionsByName' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation searchRegionChildren + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionChildren($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren'][0]) + { + list($response) = $this->searchRegionChildrenWithHttpInfo($region_id, $page, $page_size, $contentType); + return $response; + } + + /** + * Operation searchRegionChildrenWithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionWithChildrenResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionChildrenWithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren'][0]) + { + $request = $this->searchRegionChildrenRequest($region_id, $page, $page_size, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionWithChildrenResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionWithChildrenResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionChildrenAsync + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildrenAsync($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren'][0]) + { + return $this->searchRegionChildrenAsyncWithHttpInfo($region_id, $page, $page_size, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionChildrenAsyncWithHttpInfo + * + * Информация о дочерних регионах + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionChildrenAsyncWithHttpInfo($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionWithChildrenResponse'; + $request = $this->searchRegionChildrenRequest($region_id, $page, $page_size, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionChildren' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param int $page Номер страницы результатов. Используется вместе с параметром `page_size`. `page_number` игнорируется, если задан `page_token`, `limit` или `offset`. (optional, default to 1) + * @param int $page_size Размер страницы. Используется вместе с параметром `page_number`. `page_size` игнорируется, если задан `page_token`, `limit` или `offset`. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionChildren'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionChildrenRequest($region_id, $page = 1, $page_size = null, string $contentType = self::contentTypes['searchRegionChildren'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionChildren' + ); + } + + if ($page !== null && $page > 10000) { + throw new \InvalidArgumentException('invalid value for "$page" when calling RegionsApi.searchRegionChildren, must be smaller than or equal to 10000.'); + } + + + + $resourcePath = '/regions/{regionId}/children'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page, + 'page', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_size, + 'pageSize', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsById + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsById($region_id, string $contentType = self::contentTypes['searchRegionsById'][0]) + { + list($response) = $this->searchRegionsByIdWithHttpInfo($region_id, $contentType); + return $response; + } + + /** + * Operation searchRegionsByIdWithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsByIdWithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById'][0]) + { + $request = $this->searchRegionsByIdRequest($region_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsByIdAsync + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByIdAsync($region_id, string $contentType = self::contentTypes['searchRegionsById'][0]) + { + return $this->searchRegionsByIdAsyncWithHttpInfo($region_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsByIdAsyncWithHttpInfo + * + * Информация о регионе + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByIdAsyncWithHttpInfo($region_id, string $contentType = self::contentTypes['searchRegionsById'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsByIdRequest($region_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsById' + * + * @param int $region_id Идентификатор региона. Идентификатор региона можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsById'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsByIdRequest($region_id, string $contentType = self::contentTypes['searchRegionsById'][0]) + { + + // verify the required parameter 'region_id' is set + if ($region_id === null || (is_array($region_id) && count($region_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $region_id when calling searchRegionsById' + ); + } + + + $resourcePath = '/regions/{regionId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($region_id !== null) { + $resourcePath = str_replace( + '{' . 'regionId' . '}', + ObjectSerializer::toPathValue($region_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchRegionsByName + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchRegionsByName($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName'][0]) + { + list($response) = $this->searchRegionsByNameWithHttpInfo($name, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation searchRegionsByNameWithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetRegionsResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchRegionsByNameWithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName'][0]) + { + $request = $this->searchRegionsByNameRequest($name, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetRegionsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetRegionsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetRegionsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetRegionsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchRegionsByNameAsync + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByNameAsync($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName'][0]) + { + return $this->searchRegionsByNameAsyncWithHttpInfo($name, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchRegionsByNameAsyncWithHttpInfo + * + * Поиск регионов по их имени + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchRegionsByNameAsyncWithHttpInfo($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetRegionsResponse'; + $request = $this->searchRegionsByNameRequest($name, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchRegionsByName' + * + * @param string $name Название региона. Важно учитывать регистр: первая буква должна быть заглавной, остальные — строчными. Например, `Москва`. (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchRegionsByName'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchRegionsByNameRequest($name, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchRegionsByName'][0]) + { + + // verify the required parameter 'name' is set + if ($name === null || (is_array($name) && count($name) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $name when calling searchRegionsByName' + ); + } + + + + + $resourcePath = '/regions'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $name, + 'name', // param base name + 'string', // openApiType + '', // style + false, // explode + true // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/ReportsApi.php b/erp24/lib/yandex_market_api/Api/ReportsApi.php new file mode 100644 index 00000000..448ac311 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/ReportsApi.php @@ -0,0 +1,8290 @@ + [ + 'application/json', + ], + 'generateCompetitorsPositionReport' => [ + 'application/json', + ], + 'generateGoodsFeedbackReport' => [ + 'application/json', + ], + 'generateGoodsMovementReport' => [ + 'application/json', + ], + 'generateGoodsRealizationReport' => [ + 'application/json', + ], + 'generateGoodsTurnoverReport' => [ + 'application/json', + ], + 'generateMassOrderLabelsReport' => [ + 'application/json', + ], + 'generatePricesReport' => [ + 'application/json', + ], + 'generateShelfsStatisticsReport' => [ + 'application/json', + ], + 'generateShipmentListDocumentReport' => [ + 'application/json', + ], + 'generateShowsSalesReport' => [ + 'application/json', + ], + 'generateStocksOnWarehousesReport' => [ + 'application/json', + ], + 'generateUnitedMarketplaceServicesReport' => [ + 'application/json', + ], + 'generateUnitedNettingReport' => [ + 'application/json', + ], + 'generateUnitedOrdersReport' => [ + 'application/json', + ], + 'getReportInfo' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation generateBoostConsolidatedReport + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateBoostConsolidatedReport($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport'][0]) + { + list($response) = $this->generateBoostConsolidatedReportWithHttpInfo($generate_boost_consolidated_request, $format, $contentType); + return $response; + } + + /** + * Operation generateBoostConsolidatedReportWithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateBoostConsolidatedReportWithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport'][0]) + { + $request = $this->generateBoostConsolidatedReportRequest($generate_boost_consolidated_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateBoostConsolidatedReportAsync + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReportAsync($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport'][0]) + { + return $this->generateBoostConsolidatedReportAsyncWithHttpInfo($generate_boost_consolidated_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateBoostConsolidatedReportAsyncWithHttpInfo + * + * Отчет по бусту продаж + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateBoostConsolidatedReportAsyncWithHttpInfo($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateBoostConsolidatedReportRequest($generate_boost_consolidated_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateBoostConsolidatedReport' + * + * @param \OpenAPI\Client\Model\GenerateBoostConsolidatedRequest $generate_boost_consolidated_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateBoostConsolidatedReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateBoostConsolidatedReportRequest($generate_boost_consolidated_request, $format = null, string $contentType = self::contentTypes['generateBoostConsolidatedReport'][0]) + { + + // verify the required parameter 'generate_boost_consolidated_request' is set + if ($generate_boost_consolidated_request === null || (is_array($generate_boost_consolidated_request) && count($generate_boost_consolidated_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_boost_consolidated_request when calling generateBoostConsolidatedReport' + ); + } + + + + $resourcePath = '/reports/boost-consolidated/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_boost_consolidated_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_boost_consolidated_request)); + } else { + $httpBody = $generate_boost_consolidated_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateCompetitorsPositionReport + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateCompetitorsPositionReport($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport'][0]) + { + list($response) = $this->generateCompetitorsPositionReportWithHttpInfo($generate_competitors_position_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateCompetitorsPositionReportWithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateCompetitorsPositionReportWithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport'][0]) + { + $request = $this->generateCompetitorsPositionReportRequest($generate_competitors_position_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateCompetitorsPositionReportAsync + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReportAsync($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport'][0]) + { + return $this->generateCompetitorsPositionReportAsyncWithHttpInfo($generate_competitors_position_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateCompetitorsPositionReportAsyncWithHttpInfo + * + * Отчет «Конкурентная позиция» + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateCompetitorsPositionReportAsyncWithHttpInfo($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateCompetitorsPositionReportRequest($generate_competitors_position_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateCompetitorsPositionReport' + * + * @param \OpenAPI\Client\Model\GenerateCompetitorsPositionReportRequest $generate_competitors_position_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateCompetitorsPositionReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateCompetitorsPositionReportRequest($generate_competitors_position_report_request, $format = null, string $contentType = self::contentTypes['generateCompetitorsPositionReport'][0]) + { + + // verify the required parameter 'generate_competitors_position_report_request' is set + if ($generate_competitors_position_report_request === null || (is_array($generate_competitors_position_report_request) && count($generate_competitors_position_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_competitors_position_report_request when calling generateCompetitorsPositionReport' + ); + } + + + + $resourcePath = '/reports/competitors-position/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_competitors_position_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_competitors_position_report_request)); + } else { + $httpBody = $generate_competitors_position_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsFeedbackReport + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsFeedbackReport($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport'][0]) + { + list($response) = $this->generateGoodsFeedbackReportWithHttpInfo($generate_goods_feedback_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsFeedbackReportWithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsFeedbackReportWithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport'][0]) + { + $request = $this->generateGoodsFeedbackReportRequest($generate_goods_feedback_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsFeedbackReportAsync + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReportAsync($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport'][0]) + { + return $this->generateGoodsFeedbackReportAsyncWithHttpInfo($generate_goods_feedback_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsFeedbackReportAsyncWithHttpInfo + * + * Отчет по отзывам о товарах + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsFeedbackReportAsyncWithHttpInfo($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsFeedbackReportRequest($generate_goods_feedback_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsFeedbackReport' + * + * @param \OpenAPI\Client\Model\GenerateGoodsFeedbackRequest $generate_goods_feedback_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsFeedbackReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsFeedbackReportRequest($generate_goods_feedback_request, $format = null, string $contentType = self::contentTypes['generateGoodsFeedbackReport'][0]) + { + + // verify the required parameter 'generate_goods_feedback_request' is set + if ($generate_goods_feedback_request === null || (is_array($generate_goods_feedback_request) && count($generate_goods_feedback_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_feedback_request when calling generateGoodsFeedbackReport' + ); + } + + + + $resourcePath = '/reports/goods-feedback/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_feedback_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_feedback_request)); + } else { + $httpBody = $generate_goods_feedback_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsMovementReport + * + * Отчет по движению товаров + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsMovementReport($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport'][0]) + { + list($response) = $this->generateGoodsMovementReportWithHttpInfo($generate_goods_movement_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsMovementReportWithHttpInfo + * + * Отчет по движению товаров + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsMovementReportWithHttpInfo($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport'][0]) + { + $request = $this->generateGoodsMovementReportRequest($generate_goods_movement_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsMovementReportAsync + * + * Отчет по движению товаров + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsMovementReportAsync($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport'][0]) + { + return $this->generateGoodsMovementReportAsyncWithHttpInfo($generate_goods_movement_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsMovementReportAsyncWithHttpInfo + * + * Отчет по движению товаров + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsMovementReportAsyncWithHttpInfo($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsMovementReportRequest($generate_goods_movement_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsMovementReport' + * + * @param \OpenAPI\Client\Model\GenerateGoodsMovementReportRequest $generate_goods_movement_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsMovementReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsMovementReportRequest($generate_goods_movement_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsMovementReport'][0]) + { + + // verify the required parameter 'generate_goods_movement_report_request' is set + if ($generate_goods_movement_report_request === null || (is_array($generate_goods_movement_report_request) && count($generate_goods_movement_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_movement_report_request when calling generateGoodsMovementReport' + ); + } + + + + $resourcePath = '/reports/goods-movement/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_movement_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_movement_report_request)); + } else { + $httpBody = $generate_goods_movement_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsRealizationReport + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsRealizationReport($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport'][0]) + { + list($response) = $this->generateGoodsRealizationReportWithHttpInfo($generate_goods_realization_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsRealizationReportWithHttpInfo + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsRealizationReportWithHttpInfo($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport'][0]) + { + $request = $this->generateGoodsRealizationReportRequest($generate_goods_realization_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsRealizationReportAsync + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsRealizationReportAsync($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport'][0]) + { + return $this->generateGoodsRealizationReportAsyncWithHttpInfo($generate_goods_realization_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsRealizationReportAsyncWithHttpInfo + * + * Отчет по реализации + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsRealizationReportAsyncWithHttpInfo($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsRealizationReportRequest($generate_goods_realization_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsRealizationReport' + * + * @param \OpenAPI\Client\Model\GenerateGoodsRealizationReportRequest $generate_goods_realization_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsRealizationReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsRealizationReportRequest($generate_goods_realization_report_request, $format = null, string $contentType = self::contentTypes['generateGoodsRealizationReport'][0]) + { + + // verify the required parameter 'generate_goods_realization_report_request' is set + if ($generate_goods_realization_report_request === null || (is_array($generate_goods_realization_report_request) && count($generate_goods_realization_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_realization_report_request when calling generateGoodsRealizationReport' + ); + } + + + + $resourcePath = '/reports/goods-realization/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_realization_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_realization_report_request)); + } else { + $httpBody = $generate_goods_realization_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateGoodsTurnoverReport + * + * Отчет по оборачиваемости + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateGoodsTurnoverReport($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport'][0]) + { + list($response) = $this->generateGoodsTurnoverReportWithHttpInfo($generate_goods_turnover_request, $format, $contentType); + return $response; + } + + /** + * Operation generateGoodsTurnoverReportWithHttpInfo + * + * Отчет по оборачиваемости + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateGoodsTurnoverReportWithHttpInfo($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport'][0]) + { + $request = $this->generateGoodsTurnoverReportRequest($generate_goods_turnover_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateGoodsTurnoverReportAsync + * + * Отчет по оборачиваемости + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsTurnoverReportAsync($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport'][0]) + { + return $this->generateGoodsTurnoverReportAsyncWithHttpInfo($generate_goods_turnover_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateGoodsTurnoverReportAsyncWithHttpInfo + * + * Отчет по оборачиваемости + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateGoodsTurnoverReportAsyncWithHttpInfo($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateGoodsTurnoverReportRequest($generate_goods_turnover_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateGoodsTurnoverReport' + * + * @param \OpenAPI\Client\Model\GenerateGoodsTurnoverRequest $generate_goods_turnover_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateGoodsTurnoverReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateGoodsTurnoverReportRequest($generate_goods_turnover_request, $format = null, string $contentType = self::contentTypes['generateGoodsTurnoverReport'][0]) + { + + // verify the required parameter 'generate_goods_turnover_request' is set + if ($generate_goods_turnover_request === null || (is_array($generate_goods_turnover_request) && count($generate_goods_turnover_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_goods_turnover_request when calling generateGoodsTurnoverReport' + ); + } + + + + $resourcePath = '/reports/goods-turnover/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_goods_turnover_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_goods_turnover_request)); + } else { + $httpBody = $generate_goods_turnover_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateMassOrderLabelsReport + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateMassOrderLabelsReport($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport'][0]) + { + list($response) = $this->generateMassOrderLabelsReportWithHttpInfo($generate_mass_order_labels_request, $format, $contentType); + return $response; + } + + /** + * Operation generateMassOrderLabelsReportWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateMassOrderLabelsReportWithHttpInfo($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport'][0]) + { + $request = $this->generateMassOrderLabelsReportRequest($generate_mass_order_labels_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateMassOrderLabelsReportAsync + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateMassOrderLabelsReportAsync($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport'][0]) + { + return $this->generateMassOrderLabelsReportAsyncWithHttpInfo($generate_mass_order_labels_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateMassOrderLabelsReportAsyncWithHttpInfo + * + * Готовые ярлыки‑наклейки на все коробки в нескольких заказах + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateMassOrderLabelsReportAsyncWithHttpInfo($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateMassOrderLabelsReportRequest($generate_mass_order_labels_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateMassOrderLabelsReport' + * + * @param \OpenAPI\Client\Model\GenerateMassOrderLabelsRequest $generate_mass_order_labels_request (required) + * @param \OpenAPI\Client\Model\PageFormatType $format Настройка размещения ярлыков на странице. Если параметра нет, возвращается PDF с ярлыками формата A7. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateMassOrderLabelsReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateMassOrderLabelsReportRequest($generate_mass_order_labels_request, $format = null, string $contentType = self::contentTypes['generateMassOrderLabelsReport'][0]) + { + + // verify the required parameter 'generate_mass_order_labels_request' is set + if ($generate_mass_order_labels_request === null || (is_array($generate_mass_order_labels_request) && count($generate_mass_order_labels_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_mass_order_labels_request when calling generateMassOrderLabelsReport' + ); + } + + + + $resourcePath = '/reports/documents/labels/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'PageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_mass_order_labels_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_mass_order_labels_request)); + } else { + $httpBody = $generate_mass_order_labels_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generatePricesReport + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generatePricesReport($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport'][0]) + { + list($response) = $this->generatePricesReportWithHttpInfo($generate_prices_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generatePricesReportWithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generatePricesReportWithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport'][0]) + { + $request = $this->generatePricesReportRequest($generate_prices_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generatePricesReportAsync + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReportAsync($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport'][0]) + { + return $this->generatePricesReportAsyncWithHttpInfo($generate_prices_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generatePricesReportAsyncWithHttpInfo + * + * Отчет «Цены на рынке» + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generatePricesReportAsyncWithHttpInfo($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generatePricesReportRequest($generate_prices_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generatePricesReport' + * + * @param \OpenAPI\Client\Model\GeneratePricesReportRequest $generate_prices_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generatePricesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generatePricesReportRequest($generate_prices_report_request, $format = null, string $contentType = self::contentTypes['generatePricesReport'][0]) + { + + // verify the required parameter 'generate_prices_report_request' is set + if ($generate_prices_report_request === null || (is_array($generate_prices_report_request) && count($generate_prices_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_prices_report_request when calling generatePricesReport' + ); + } + + + + $resourcePath = '/reports/prices/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_prices_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_prices_report_request)); + } else { + $httpBody = $generate_prices_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShelfsStatisticsReport + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShelfsStatisticsReport($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport'][0]) + { + list($response) = $this->generateShelfsStatisticsReportWithHttpInfo($generate_shelfs_statistics_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShelfsStatisticsReportWithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShelfsStatisticsReportWithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport'][0]) + { + $request = $this->generateShelfsStatisticsReportRequest($generate_shelfs_statistics_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShelfsStatisticsReportAsync + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReportAsync($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport'][0]) + { + return $this->generateShelfsStatisticsReportAsyncWithHttpInfo($generate_shelfs_statistics_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShelfsStatisticsReportAsyncWithHttpInfo + * + * Отчет по полкам + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShelfsStatisticsReportAsyncWithHttpInfo($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShelfsStatisticsReportRequest($generate_shelfs_statistics_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShelfsStatisticsReport' + * + * @param \OpenAPI\Client\Model\GenerateShelfsStatisticsRequest $generate_shelfs_statistics_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShelfsStatisticsReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShelfsStatisticsReportRequest($generate_shelfs_statistics_request, $format = null, string $contentType = self::contentTypes['generateShelfsStatisticsReport'][0]) + { + + // verify the required parameter 'generate_shelfs_statistics_request' is set + if ($generate_shelfs_statistics_request === null || (is_array($generate_shelfs_statistics_request) && count($generate_shelfs_statistics_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shelfs_statistics_request when calling generateShelfsStatisticsReport' + ); + } + + + + $resourcePath = '/reports/shelf-statistics/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shelfs_statistics_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shelfs_statistics_request)); + } else { + $httpBody = $generate_shelfs_statistics_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShipmentListDocumentReport + * + * Получение листа сборки + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShipmentListDocumentReport($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport'][0]) + { + list($response) = $this->generateShipmentListDocumentReportWithHttpInfo($generate_shipment_list_document_report_request, $contentType); + return $response; + } + + /** + * Operation generateShipmentListDocumentReportWithHttpInfo + * + * Получение листа сборки + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShipmentListDocumentReportWithHttpInfo($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport'][0]) + { + $request = $this->generateShipmentListDocumentReportRequest($generate_shipment_list_document_report_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShipmentListDocumentReportAsync + * + * Получение листа сборки + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShipmentListDocumentReportAsync($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport'][0]) + { + return $this->generateShipmentListDocumentReportAsyncWithHttpInfo($generate_shipment_list_document_report_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShipmentListDocumentReportAsyncWithHttpInfo + * + * Получение листа сборки + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShipmentListDocumentReportAsyncWithHttpInfo($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShipmentListDocumentReportRequest($generate_shipment_list_document_report_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShipmentListDocumentReport' + * + * @param \OpenAPI\Client\Model\GenerateShipmentListDocumentReportRequest $generate_shipment_list_document_report_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShipmentListDocumentReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShipmentListDocumentReportRequest($generate_shipment_list_document_report_request, string $contentType = self::contentTypes['generateShipmentListDocumentReport'][0]) + { + + // verify the required parameter 'generate_shipment_list_document_report_request' is set + if ($generate_shipment_list_document_report_request === null || (is_array($generate_shipment_list_document_report_request) && count($generate_shipment_list_document_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shipment_list_document_report_request when calling generateShipmentListDocumentReport' + ); + } + + + $resourcePath = '/reports/documents/shipment-list/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shipment_list_document_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shipment_list_document_report_request)); + } else { + $httpBody = $generate_shipment_list_document_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateShowsSalesReport + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateShowsSalesReport($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport'][0]) + { + list($response) = $this->generateShowsSalesReportWithHttpInfo($generate_shows_sales_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateShowsSalesReportWithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateShowsSalesReportWithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport'][0]) + { + $request = $this->generateShowsSalesReportRequest($generate_shows_sales_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateShowsSalesReportAsync + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReportAsync($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport'][0]) + { + return $this->generateShowsSalesReportAsyncWithHttpInfo($generate_shows_sales_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateShowsSalesReportAsyncWithHttpInfo + * + * Отчет «Аналитика продаж» + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateShowsSalesReportAsyncWithHttpInfo($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateShowsSalesReportRequest($generate_shows_sales_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateShowsSalesReport' + * + * @param \OpenAPI\Client\Model\GenerateShowsSalesReportRequest $generate_shows_sales_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateShowsSalesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateShowsSalesReportRequest($generate_shows_sales_report_request, $format = null, string $contentType = self::contentTypes['generateShowsSalesReport'][0]) + { + + // verify the required parameter 'generate_shows_sales_report_request' is set + if ($generate_shows_sales_report_request === null || (is_array($generate_shows_sales_report_request) && count($generate_shows_sales_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_shows_sales_report_request when calling generateShowsSalesReport' + ); + } + + + + $resourcePath = '/reports/shows-sales/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_shows_sales_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_shows_sales_report_request)); + } else { + $httpBody = $generate_shows_sales_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateStocksOnWarehousesReport + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateStocksOnWarehousesReport($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport'][0]) + { + list($response) = $this->generateStocksOnWarehousesReportWithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateStocksOnWarehousesReportWithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateStocksOnWarehousesReportWithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport'][0]) + { + $request = $this->generateStocksOnWarehousesReportRequest($generate_stocks_on_warehouses_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateStocksOnWarehousesReportAsync + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReportAsync($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport'][0]) + { + return $this->generateStocksOnWarehousesReportAsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateStocksOnWarehousesReportAsyncWithHttpInfo + * + * Отчет по остаткам на складах + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateStocksOnWarehousesReportAsyncWithHttpInfo($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateStocksOnWarehousesReportRequest($generate_stocks_on_warehouses_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateStocksOnWarehousesReport' + * + * @param \OpenAPI\Client\Model\GenerateStocksOnWarehousesReportRequest $generate_stocks_on_warehouses_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateStocksOnWarehousesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateStocksOnWarehousesReportRequest($generate_stocks_on_warehouses_report_request, $format = null, string $contentType = self::contentTypes['generateStocksOnWarehousesReport'][0]) + { + + // verify the required parameter 'generate_stocks_on_warehouses_report_request' is set + if ($generate_stocks_on_warehouses_report_request === null || (is_array($generate_stocks_on_warehouses_report_request) && count($generate_stocks_on_warehouses_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_stocks_on_warehouses_report_request when calling generateStocksOnWarehousesReport' + ); + } + + + + $resourcePath = '/reports/stocks-on-warehouses/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_stocks_on_warehouses_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_stocks_on_warehouses_report_request)); + } else { + $httpBody = $generate_stocks_on_warehouses_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReport + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedMarketplaceServicesReport($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport'][0]) + { + list($response) = $this->generateUnitedMarketplaceServicesReportWithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedMarketplaceServicesReportWithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedMarketplaceServicesReportWithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport'][0]) + { + $request = $this->generateUnitedMarketplaceServicesReportRequest($generate_united_marketplace_services_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedMarketplaceServicesReportAsync + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReportAsync($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport'][0]) + { + return $this->generateUnitedMarketplaceServicesReportAsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedMarketplaceServicesReportAsyncWithHttpInfo + * + * Отчет по стоимости услуг + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedMarketplaceServicesReportAsyncWithHttpInfo($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedMarketplaceServicesReportRequest($generate_united_marketplace_services_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedMarketplaceServicesReport' + * + * @param \OpenAPI\Client\Model\GenerateUnitedMarketplaceServicesReportRequest $generate_united_marketplace_services_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedMarketplaceServicesReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedMarketplaceServicesReportRequest($generate_united_marketplace_services_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedMarketplaceServicesReport'][0]) + { + + // verify the required parameter 'generate_united_marketplace_services_report_request' is set + if ($generate_united_marketplace_services_report_request === null || (is_array($generate_united_marketplace_services_report_request) && count($generate_united_marketplace_services_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_marketplace_services_report_request when calling generateUnitedMarketplaceServicesReport' + ); + } + + + + $resourcePath = '/reports/united-marketplace-services/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_marketplace_services_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_marketplace_services_report_request)); + } else { + $httpBody = $generate_united_marketplace_services_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedNettingReport + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedNettingReport($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport'][0]) + { + list($response) = $this->generateUnitedNettingReportWithHttpInfo($generate_united_netting_report_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedNettingReportWithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedNettingReportWithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport'][0]) + { + $request = $this->generateUnitedNettingReportRequest($generate_united_netting_report_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedNettingReportAsync + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReportAsync($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport'][0]) + { + return $this->generateUnitedNettingReportAsyncWithHttpInfo($generate_united_netting_report_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedNettingReportAsyncWithHttpInfo + * + * Отчет по платежам + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedNettingReportAsyncWithHttpInfo($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedNettingReportRequest($generate_united_netting_report_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedNettingReport' + * + * @param \OpenAPI\Client\Model\GenerateUnitedNettingReportRequest $generate_united_netting_report_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedNettingReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedNettingReportRequest($generate_united_netting_report_request, $format = null, string $contentType = self::contentTypes['generateUnitedNettingReport'][0]) + { + + // verify the required parameter 'generate_united_netting_report_request' is set + if ($generate_united_netting_report_request === null || (is_array($generate_united_netting_report_request) && count($generate_united_netting_report_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_netting_report_request when calling generateUnitedNettingReport' + ); + } + + + + $resourcePath = '/reports/united-netting/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_netting_report_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_netting_report_request)); + } else { + $httpBody = $generate_united_netting_report_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation generateUnitedOrdersReport + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function generateUnitedOrdersReport($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport'][0]) + { + list($response) = $this->generateUnitedOrdersReportWithHttpInfo($generate_united_orders_request, $format, $contentType); + return $response; + } + + /** + * Operation generateUnitedOrdersReportWithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GenerateReportResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function generateUnitedOrdersReportWithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport'][0]) + { + $request = $this->generateUnitedOrdersReportRequest($generate_united_orders_request, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GenerateReportResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GenerateReportResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GenerateReportResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GenerateReportResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation generateUnitedOrdersReportAsync + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReportAsync($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport'][0]) + { + return $this->generateUnitedOrdersReportAsyncWithHttpInfo($generate_united_orders_request, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation generateUnitedOrdersReportAsyncWithHttpInfo + * + * Отчет по заказам + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function generateUnitedOrdersReportAsyncWithHttpInfo($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport'][0]) + { + $returnType = '\OpenAPI\Client\Model\GenerateReportResponse'; + $request = $this->generateUnitedOrdersReportRequest($generate_united_orders_request, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'generateUnitedOrdersReport' + * + * @param \OpenAPI\Client\Model\GenerateUnitedOrdersRequest $generate_united_orders_request (required) + * @param \OpenAPI\Client\Model\ReportFormatType $format Формат отчета. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['generateUnitedOrdersReport'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function generateUnitedOrdersReportRequest($generate_united_orders_request, $format = null, string $contentType = self::contentTypes['generateUnitedOrdersReport'][0]) + { + + // verify the required parameter 'generate_united_orders_request' is set + if ($generate_united_orders_request === null || (is_array($generate_united_orders_request) && count($generate_united_orders_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $generate_united_orders_request when calling generateUnitedOrdersReport' + ); + } + + + + $resourcePath = '/reports/united-orders/generate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ReportFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($generate_united_orders_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($generate_united_orders_request)); + } else { + $httpBody = $generate_united_orders_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReportInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReportInfo($report_id, string $contentType = self::contentTypes['getReportInfo'][0]) + { + list($response) = $this->getReportInfoWithHttpInfo($report_id, $contentType); + return $response; + } + + /** + * Operation getReportInfoWithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReportInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReportInfoWithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo'][0]) + { + $request = $this->getReportInfoRequest($report_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReportInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReportInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReportInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReportInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReportInfoAsync + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfoAsync($report_id, string $contentType = self::contentTypes['getReportInfo'][0]) + { + return $this->getReportInfoAsyncWithHttpInfo($report_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReportInfoAsyncWithHttpInfo + * + * Получение заданного отчета + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReportInfoAsyncWithHttpInfo($report_id, string $contentType = self::contentTypes['getReportInfo'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReportInfoResponse'; + $request = $this->getReportInfoRequest($report_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReportInfo' + * + * @param string $report_id Идентификатор отчета, который вы получили после запуска генерации. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReportInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReportInfoRequest($report_id, string $contentType = self::contentTypes['getReportInfo'][0]) + { + + // verify the required parameter 'report_id' is set + if ($report_id === null || (is_array($report_id) && count($report_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $report_id when calling getReportInfo' + ); + } + + + $resourcePath = '/reports/info/{reportId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($report_id !== null) { + $resourcePath = str_replace( + '{' . 'reportId' . '}', + ObjectSerializer::toPathValue($report_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/ReturnsApi.php b/erp24/lib/yandex_market_api/Api/ReturnsApi.php new file mode 100644 index 00000000..fcdbec16 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/ReturnsApi.php @@ -0,0 +1,3735 @@ + [ + 'application/json', + ], + 'getReturnApplication' => [ + 'application/json', + ], + 'getReturnPhoto' => [ + 'application/json', + ], + 'getReturns' => [ + 'application/json', + ], + 'setReturnDecision' => [ + 'application/json', + ], + 'submitReturnDecision' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getReturn + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturn($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn'][0]) + { + list($response) = $this->getReturnWithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturnWithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn'][0]) + { + $request = $this->getReturnRequest($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnAsync + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnAsync($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn'][0]) + { + return $this->getReturnAsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnAsyncWithHttpInfo + * + * Информация о невыкупе или возврате + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnAsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnResponse'; + $request = $this->getReturnRequest($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturn' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturn'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnRequest($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturn'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturn' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ReturnsApi.getReturn, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturn' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturn' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnApplication + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnApplication($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication'][0]) + { + list($response) = $this->getReturnApplicationWithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation getReturnApplicationWithHttpInfo + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnApplicationWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication'][0]) + { + $request = $this->getReturnApplicationRequest($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnApplicationAsync + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnApplicationAsync($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication'][0]) + { + return $this->getReturnApplicationAsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnApplicationAsyncWithHttpInfo + * + * Получение заявления на возврат + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnApplicationAsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnApplicationRequest($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnApplication' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnApplication'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnApplicationRequest($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['getReturnApplication'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnApplication' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ReturnsApi.getReturnApplication, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnApplication' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnApplication' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/application'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturnPhoto + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturnPhoto($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto'][0]) + { + list($response) = $this->getReturnPhotoWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + return $response; + } + + /** + * Operation getReturnPhotoWithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnPhotoWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto'][0]) + { + $request = $this->getReturnPhotoRequest($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnPhotoAsync + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhotoAsync($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto'][0]) + { + return $this->getReturnPhotoAsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnPhotoAsyncWithHttpInfo + * + * Получение фотографии возврата + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnPhotoAsyncWithHttpInfo($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->getReturnPhotoRequest($campaign_id, $order_id, $return_id, $item_id, $image_hash, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturnPhoto' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param int $item_id Идентификатор товара в возврате. (required) + * @param string $image_hash Хеш ссылки изображения для загрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturnPhoto'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnPhotoRequest($campaign_id, $order_id, $return_id, $item_id, $image_hash, string $contentType = self::contentTypes['getReturnPhoto'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturnPhoto' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ReturnsApi.getReturnPhoto, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getReturnPhoto' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling getReturnPhoto' + ); + } + + // verify the required parameter 'item_id' is set + if ($item_id === null || (is_array($item_id) && count($item_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $item_id when calling getReturnPhoto' + ); + } + + // verify the required parameter 'image_hash' is set + if ($image_hash === null || (is_array($image_hash) && count($image_hash) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $image_hash when calling getReturnPhoto' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision/{itemId}/image/{imageHash}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + // path params + if ($item_id !== null) { + $resourcePath = str_replace( + '{' . 'itemId' . '}', + ObjectSerializer::toPathValue($item_id), + $resourcePath + ); + } + // path params + if ($image_hash !== null) { + $resourcePath = str_replace( + '{' . 'imageHash' . '}', + ObjectSerializer::toPathValue($image_hash), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/octet-stream', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getReturns + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getReturns($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns'][0]) + { + list($response) = $this->getReturnsWithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + return $response; + } + + /** + * Operation getReturnsWithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetReturnsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getReturnsWithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns'][0]) + { + $request = $this->getReturnsRequest($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetReturnsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetReturnsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetReturnsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetReturnsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getReturnsAsync + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnsAsync($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns'][0]) + { + return $this->getReturnsAsyncWithHttpInfo($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getReturnsAsyncWithHttpInfo + * + * Список невыкупов и возвратов + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getReturnsAsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetReturnsResponse'; + $request = $this->getReturnsRequest($campaign_id, $page_token, $limit, $order_ids, $statuses, $type, $from_date, $to_date, $from_date2, $to_date2, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getReturns' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param int[] $order_ids Идентификаторы заказов — для фильтрации результатов. Несколько идентификаторов перечисляются через запятую без пробела. (optional) + * @param \OpenAPI\Client\Model\RefundStatusType[] $statuses Статусы возвратов или невыкупов — для фильтрации результатов. Несколько статусов перечисляются через запятую. (optional) + * @param \OpenAPI\Client\Model\ReturnType $type Тип заказа для фильтрации: * `RETURN` — возврат. * `UNREDEEMED` — невыкуп. Если не указывать, в ответе будут и возвраты, и невыкупы. (optional) + * @param \DateTime $from_date Начальная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $to_date Конечная дата для фильтрации возвратов или невыкупов по дате обновления. Формат: `ГГГГ-ММ-ДД`. (optional) + * @param \DateTime $from_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `fromDate`. {% endnote %} Начальная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param \DateTime $to_date2 {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `toDate`. {% endnote %} Конечная дата для фильтрации возвратов или невыкупов по дате обновления. (optional) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getReturns'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getReturnsRequest($campaign_id, $page_token = null, $limit = null, $order_ids = null, $statuses = null, $type = null, $from_date = null, $to_date = null, $from_date2 = null, $to_date2 = null, string $contentType = self::contentTypes['getReturns'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getReturns' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ReturnsApi.getReturns, must be bigger than or equal to 1.'); + } + + + + if ($order_ids !== null && count($order_ids) > 50) { + throw new \InvalidArgumentException('invalid value for "$order_ids" when calling ReturnsApi.getReturns, number of items must be less than or equal to 50.'); + } + + + + + + + + + $resourcePath = '/campaigns/{campaignId}/returns'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $order_ids, + 'orderIds', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $statuses, + 'statuses', // param base name + 'array', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $type, + 'type', // param base name + 'ReturnType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date, + 'fromDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date, + 'toDate', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $from_date2, + 'from_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $to_date2, + 'to_date', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setReturnDecision + * + * Принятие или изменение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setReturnDecision($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision'][0]) + { + list($response) = $this->setReturnDecisionWithHttpInfo($campaign_id, $order_id, $return_id, $set_return_decision_request, $contentType); + return $response; + } + + /** + * Operation setReturnDecisionWithHttpInfo + * + * Принятие или изменение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setReturnDecisionWithHttpInfo($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision'][0]) + { + $request = $this->setReturnDecisionRequest($campaign_id, $order_id, $return_id, $set_return_decision_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setReturnDecisionAsync + * + * Принятие или изменение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setReturnDecisionAsync($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision'][0]) + { + return $this->setReturnDecisionAsyncWithHttpInfo($campaign_id, $order_id, $return_id, $set_return_decision_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setReturnDecisionAsyncWithHttpInfo + * + * Принятие или изменение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setReturnDecisionAsyncWithHttpInfo($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setReturnDecisionRequest($campaign_id, $order_id, $return_id, $set_return_decision_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setReturnDecision' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param \OpenAPI\Client\Model\SetReturnDecisionRequest $set_return_decision_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setReturnDecision'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setReturnDecisionRequest($campaign_id, $order_id, $return_id, $set_return_decision_request, string $contentType = self::contentTypes['setReturnDecision'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setReturnDecision' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ReturnsApi.setReturnDecision, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling setReturnDecision' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling setReturnDecision' + ); + } + + // verify the required parameter 'set_return_decision_request' is set + if ($set_return_decision_request === null || (is_array($set_return_decision_request) && count($set_return_decision_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_return_decision_request when calling setReturnDecision' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_return_decision_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_return_decision_request)); + } else { + $httpBody = $set_return_decision_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation submitReturnDecision + * + * Подтверждение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function submitReturnDecision($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision'][0]) + { + list($response) = $this->submitReturnDecisionWithHttpInfo($campaign_id, $order_id, $return_id, $contentType); + return $response; + } + + /** + * Operation submitReturnDecisionWithHttpInfo + * + * Подтверждение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function submitReturnDecisionWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision'][0]) + { + $request = $this->submitReturnDecisionRequest($campaign_id, $order_id, $return_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation submitReturnDecisionAsync + * + * Подтверждение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function submitReturnDecisionAsync($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision'][0]) + { + return $this->submitReturnDecisionAsyncWithHttpInfo($campaign_id, $order_id, $return_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation submitReturnDecisionAsyncWithHttpInfo + * + * Подтверждение решения по возврату + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function submitReturnDecisionAsyncWithHttpInfo($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->submitReturnDecisionRequest($campaign_id, $order_id, $return_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'submitReturnDecision' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $order_id Идентификатор заказа. (required) + * @param int $return_id Идентификатор возврата. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['submitReturnDecision'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function submitReturnDecisionRequest($campaign_id, $order_id, $return_id, string $contentType = self::contentTypes['submitReturnDecision'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling submitReturnDecision' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ReturnsApi.submitReturnDecision, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'order_id' is set + if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling submitReturnDecision' + ); + } + + // verify the required parameter 'return_id' is set + if ($return_id === null || (is_array($return_id) && count($return_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $return_id when calling submitReturnDecision' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/orders/{orderId}/returns/{returnId}/decision/submit'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($order_id !== null) { + $resourcePath = str_replace( + '{' . 'orderId' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); + } + // path params + if ($return_id !== null) { + $resourcePath = str_replace( + '{' . 'returnId' . '}', + ObjectSerializer::toPathValue($return_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/ShipmentsApi.php b/erp24/lib/yandex_market_api/Api/ShipmentsApi.php new file mode 100644 index 00000000..0bae488e --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/ShipmentsApi.php @@ -0,0 +1,6914 @@ + [ + 'application/json', + ], + 'downloadShipmentAct' => [ + 'application/json', + ], + 'downloadShipmentDiscrepancyAct' => [ + 'application/json', + ], + 'downloadShipmentInboundAct' => [ + 'application/json', + ], + 'downloadShipmentPalletLabels' => [ + 'application/json', + ], + 'downloadShipmentReceptionTransferAct' => [ + 'application/json', + ], + 'downloadShipmentTransportationWaybill' => [ + 'application/json', + ], + 'getShipment' => [ + 'application/json', + ], + 'getShipmentOrdersInfo' => [ + 'application/json', + ], + 'searchShipments' => [ + 'application/json', + ], + 'setShipmentPalletsCount' => [ + 'application/json', + ], + 'transferOrdersFromShipment' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation confirmShipment + * + * Подтверждение отгрузки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function confirmShipment($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment'][0]) + { + list($response) = $this->confirmShipmentWithHttpInfo($campaign_id, $shipment_id, $confirm_shipment_request, $contentType); + return $response; + } + + /** + * Operation confirmShipmentWithHttpInfo + * + * Подтверждение отгрузки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function confirmShipmentWithHttpInfo($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment'][0]) + { + $request = $this->confirmShipmentRequest($campaign_id, $shipment_id, $confirm_shipment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation confirmShipmentAsync + * + * Подтверждение отгрузки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmShipmentAsync($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment'][0]) + { + return $this->confirmShipmentAsyncWithHttpInfo($campaign_id, $shipment_id, $confirm_shipment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation confirmShipmentAsyncWithHttpInfo + * + * Подтверждение отгрузки + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function confirmShipmentAsyncWithHttpInfo($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->confirmShipmentRequest($campaign_id, $shipment_id, $confirm_shipment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'confirmShipment' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ConfirmShipmentRequest $confirm_shipment_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['confirmShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function confirmShipmentRequest($campaign_id, $shipment_id, $confirm_shipment_request = null, string $contentType = self::contentTypes['confirmShipment'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling confirmShipment' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.confirmShipment, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling confirmShipment' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.confirmShipment, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/confirm'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($confirm_shipment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($confirm_shipment_request)); + } else { + $httpBody = $confirm_shipment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentAct + * + * Получение акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentAct($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct'][0]) + { + list($response) = $this->downloadShipmentActWithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentActWithHttpInfo + * + * Получение акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentActWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct'][0]) + { + $request = $this->downloadShipmentActRequest($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentActAsync + * + * Получение акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentActAsync($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct'][0]) + { + return $this->downloadShipmentActAsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentActAsyncWithHttpInfo + * + * Получение акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentActAsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentActRequest($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentAct' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentActRequest($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentAct'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentAct' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.downloadShipmentAct, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentAct' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.downloadShipmentAct, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/act'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentDiscrepancyAct + * + * Получение акта расхождений + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentDiscrepancyAct($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct'][0]) + { + list($response) = $this->downloadShipmentDiscrepancyActWithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentDiscrepancyActWithHttpInfo + * + * Получение акта расхождений + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentDiscrepancyActWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct'][0]) + { + $request = $this->downloadShipmentDiscrepancyActRequest($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentDiscrepancyActAsync + * + * Получение акта расхождений + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentDiscrepancyActAsync($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct'][0]) + { + return $this->downloadShipmentDiscrepancyActAsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentDiscrepancyActAsyncWithHttpInfo + * + * Получение акта расхождений + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentDiscrepancyActAsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentDiscrepancyActRequest($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentDiscrepancyAct' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentDiscrepancyAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentDiscrepancyActRequest($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentDiscrepancyAct'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentDiscrepancyAct' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.downloadShipmentDiscrepancyAct, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentDiscrepancyAct' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.downloadShipmentDiscrepancyAct, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/discrepancy-act'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/vnd.ms-excel', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentInboundAct + * + * Получение фактического акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentInboundAct($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct'][0]) + { + list($response) = $this->downloadShipmentInboundActWithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentInboundActWithHttpInfo + * + * Получение фактического акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentInboundActWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct'][0]) + { + $request = $this->downloadShipmentInboundActRequest($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentInboundActAsync + * + * Получение фактического акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentInboundActAsync($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct'][0]) + { + return $this->downloadShipmentInboundActAsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentInboundActAsyncWithHttpInfo + * + * Получение фактического акта приема-передачи + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentInboundActAsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentInboundActRequest($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentInboundAct' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentInboundAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentInboundActRequest($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentInboundAct'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentInboundAct' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.downloadShipmentInboundAct, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentInboundAct' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.downloadShipmentInboundAct, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/inbound-act'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentPalletLabels + * + * Ярлыки для доверительной приемки (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentPalletLabels($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels'][0]) + { + list($response) = $this->downloadShipmentPalletLabelsWithHttpInfo($campaign_id, $shipment_id, $format, $contentType); + return $response; + } + + /** + * Operation downloadShipmentPalletLabelsWithHttpInfo + * + * Ярлыки для доверительной приемки (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentPalletLabelsWithHttpInfo($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels'][0]) + { + $request = $this->downloadShipmentPalletLabelsRequest($campaign_id, $shipment_id, $format, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentPalletLabelsAsync + * + * Ярлыки для доверительной приемки (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentPalletLabelsAsync($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels'][0]) + { + return $this->downloadShipmentPalletLabelsAsyncWithHttpInfo($campaign_id, $shipment_id, $format, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentPalletLabelsAsyncWithHttpInfo + * + * Ярлыки для доверительной приемки (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentPalletLabelsAsyncWithHttpInfo($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentPalletLabelsRequest($campaign_id, $shipment_id, $format, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentPalletLabels' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\ShipmentPalletLabelPageFormatType $format Формат страниц PDF-файла с ярлыками: * `A4` — по 16 ярлыков на странице. * `A8` — по одному ярлыку на странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentPalletLabels'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentPalletLabelsRequest($campaign_id, $shipment_id, $format = null, string $contentType = self::contentTypes['downloadShipmentPalletLabels'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentPalletLabels' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.downloadShipmentPalletLabels, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentPalletLabels' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.downloadShipmentPalletLabels, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/pallet/labels'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $format, + 'format', // param base name + 'ShipmentPalletLabelPageFormatType', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentReceptionTransferAct + * + * Подтверждение ближайшей отгрузки и получение акта приема-передачи для нее + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentReceptionTransferAct($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct'][0]) + { + list($response) = $this->downloadShipmentReceptionTransferActWithHttpInfo($campaign_id, $warehouse_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentReceptionTransferActWithHttpInfo + * + * Подтверждение ближайшей отгрузки и получение акта приема-передачи для нее + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentReceptionTransferActWithHttpInfo($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct'][0]) + { + $request = $this->downloadShipmentReceptionTransferActRequest($campaign_id, $warehouse_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentReceptionTransferActAsync + * + * Подтверждение ближайшей отгрузки и получение акта приема-передачи для нее + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentReceptionTransferActAsync($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct'][0]) + { + return $this->downloadShipmentReceptionTransferActAsyncWithHttpInfo($campaign_id, $warehouse_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentReceptionTransferActAsyncWithHttpInfo + * + * Подтверждение ближайшей отгрузки и получение акта приема-передачи для нее + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentReceptionTransferActAsyncWithHttpInfo($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentReceptionTransferActRequest($campaign_id, $warehouse_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentReceptionTransferAct' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $warehouse_id Идентификатор склада. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentReceptionTransferAct'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentReceptionTransferActRequest($campaign_id, $warehouse_id = null, string $contentType = self::contentTypes['downloadShipmentReceptionTransferAct'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentReceptionTransferAct' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.downloadShipmentReceptionTransferAct, must be bigger than or equal to 1.'); + } + + if ($warehouse_id !== null && $warehouse_id < 1) { + throw new \InvalidArgumentException('invalid value for "$warehouse_id" when calling ShipmentsApi.downloadShipmentReceptionTransferAct, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/shipments/reception-transfer-act'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $warehouse_id, + 'warehouse_id', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/pdf', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation downloadShipmentTransportationWaybill + * + * Получение транспортной накладной + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function downloadShipmentTransportationWaybill($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill'][0]) + { + list($response) = $this->downloadShipmentTransportationWaybillWithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation downloadShipmentTransportationWaybillWithHttpInfo + * + * Получение транспортной накладной + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \SplFileObject|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function downloadShipmentTransportationWaybillWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill'][0]) + { + $request = $this->downloadShipmentTransportationWaybillRequest($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\SplFileObject' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\SplFileObject' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\SplFileObject', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\SplFileObject'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\SplFileObject', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation downloadShipmentTransportationWaybillAsync + * + * Получение транспортной накладной + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentTransportationWaybillAsync($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill'][0]) + { + return $this->downloadShipmentTransportationWaybillAsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation downloadShipmentTransportationWaybillAsyncWithHttpInfo + * + * Получение транспортной накладной + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function downloadShipmentTransportationWaybillAsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill'][0]) + { + $returnType = '\SplFileObject'; + $request = $this->downloadShipmentTransportationWaybillRequest($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'downloadShipmentTransportationWaybill' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['downloadShipmentTransportationWaybill'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function downloadShipmentTransportationWaybillRequest($campaign_id, $shipment_id, string $contentType = self::contentTypes['downloadShipmentTransportationWaybill'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling downloadShipmentTransportationWaybill' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.downloadShipmentTransportationWaybill, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling downloadShipmentTransportationWaybill' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.downloadShipmentTransportationWaybill, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/transportation-waybill'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/vnd.ms-excel', 'application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getShipment + * + * Получение информации об одной отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetShipmentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getShipment($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment'][0]) + { + list($response) = $this->getShipmentWithHttpInfo($campaign_id, $shipment_id, $cancelled_orders, $contentType); + return $response; + } + + /** + * Operation getShipmentWithHttpInfo + * + * Получение информации об одной отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetShipmentResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getShipmentWithHttpInfo($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment'][0]) + { + $request = $this->getShipmentRequest($campaign_id, $shipment_id, $cancelled_orders, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetShipmentResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetShipmentResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetShipmentResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetShipmentResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetShipmentResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getShipmentAsync + * + * Получение информации об одной отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getShipmentAsync($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment'][0]) + { + return $this->getShipmentAsyncWithHttpInfo($campaign_id, $shipment_id, $cancelled_orders, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getShipmentAsyncWithHttpInfo + * + * Получение информации об одной отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getShipmentAsyncWithHttpInfo($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetShipmentResponse'; + $request = $this->getShipmentRequest($campaign_id, $shipment_id, $cancelled_orders, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getShipment' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param bool $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. (optional, default to true) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getShipmentRequest($campaign_id, $shipment_id, $cancelled_orders = true, string $contentType = self::contentTypes['getShipment'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getShipment' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.getShipment, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling getShipment' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.getShipment, must be bigger than or equal to 1.'); + } + + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $cancelled_orders, + 'cancelledOrders', // param base name + 'boolean', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getShipmentOrdersInfo + * + * Получение информации о возможности печати ярлыков (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetShipmentOrdersInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getShipmentOrdersInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo'][0]) + { + list($response) = $this->getShipmentOrdersInfoWithHttpInfo($campaign_id, $shipment_id, $contentType); + return $response; + } + + /** + * Operation getShipmentOrdersInfoWithHttpInfo + * + * Получение информации о возможности печати ярлыков (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetShipmentOrdersInfoResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getShipmentOrdersInfoWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo'][0]) + { + $request = $this->getShipmentOrdersInfoRequest($campaign_id, $shipment_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getShipmentOrdersInfoAsync + * + * Получение информации о возможности печати ярлыков (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getShipmentOrdersInfoAsync($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo'][0]) + { + return $this->getShipmentOrdersInfoAsyncWithHttpInfo($campaign_id, $shipment_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getShipmentOrdersInfoAsyncWithHttpInfo + * + * Получение информации о возможности печати ярлыков (FBS) + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getShipmentOrdersInfoAsyncWithHttpInfo($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetShipmentOrdersInfoResponse'; + $request = $this->getShipmentOrdersInfoRequest($campaign_id, $shipment_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getShipmentOrdersInfo' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getShipmentOrdersInfo'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getShipmentOrdersInfoRequest($campaign_id, $shipment_id, string $contentType = self::contentTypes['getShipmentOrdersInfo'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getShipmentOrdersInfo' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.getShipmentOrdersInfo, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling getShipmentOrdersInfo' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.getShipmentOrdersInfo, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/orders/info'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation searchShipments + * + * Получение информации о нескольких отгрузках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\SearchShipmentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function searchShipments($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments'][0]) + { + list($response) = $this->searchShipmentsWithHttpInfo($campaign_id, $search_shipments_request, $page_token, $limit, $contentType); + return $response; + } + + /** + * Operation searchShipmentsWithHttpInfo + * + * Получение информации о нескольких отгрузках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\SearchShipmentsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function searchShipmentsWithHttpInfo($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments'][0]) + { + $request = $this->searchShipmentsRequest($campaign_id, $search_shipments_request, $page_token, $limit, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\SearchShipmentsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\SearchShipmentsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\SearchShipmentsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\SearchShipmentsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\SearchShipmentsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation searchShipmentsAsync + * + * Получение информации о нескольких отгрузках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchShipmentsAsync($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments'][0]) + { + return $this->searchShipmentsAsyncWithHttpInfo($campaign_id, $search_shipments_request, $page_token, $limit, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation searchShipmentsAsyncWithHttpInfo + * + * Получение информации о нескольких отгрузках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function searchShipmentsAsyncWithHttpInfo($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments'][0]) + { + $returnType = '\OpenAPI\Client\Model\SearchShipmentsResponse'; + $request = $this->searchShipmentsRequest($campaign_id, $search_shipments_request, $page_token, $limit, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'searchShipments' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\SearchShipmentsRequest $search_shipments_request (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['searchShipments'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function searchShipmentsRequest($campaign_id, $search_shipments_request, $page_token = null, $limit = null, string $contentType = self::contentTypes['searchShipments'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling searchShipments' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.searchShipments, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'search_shipments_request' is set + if ($search_shipments_request === null || (is_array($search_shipments_request) && count($search_shipments_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $search_shipments_request when calling searchShipments' + ); + } + + + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($search_shipments_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($search_shipments_request)); + } else { + $httpBody = $search_shipments_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation setShipmentPalletsCount + * + * Передача количества упаковок в отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function setShipmentPalletsCount($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount'][0]) + { + list($response) = $this->setShipmentPalletsCountWithHttpInfo($campaign_id, $shipment_id, $set_shipment_pallets_count_request, $contentType); + return $response; + } + + /** + * Operation setShipmentPalletsCountWithHttpInfo + * + * Передача количества упаковок в отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function setShipmentPalletsCountWithHttpInfo($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount'][0]) + { + $request = $this->setShipmentPalletsCountRequest($campaign_id, $shipment_id, $set_shipment_pallets_count_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation setShipmentPalletsCountAsync + * + * Передача количества упаковок в отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setShipmentPalletsCountAsync($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount'][0]) + { + return $this->setShipmentPalletsCountAsyncWithHttpInfo($campaign_id, $shipment_id, $set_shipment_pallets_count_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation setShipmentPalletsCountAsyncWithHttpInfo + * + * Передача количества упаковок в отгрузке + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function setShipmentPalletsCountAsyncWithHttpInfo($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->setShipmentPalletsCountRequest($campaign_id, $shipment_id, $set_shipment_pallets_count_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'setShipmentPalletsCount' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\SetShipmentPalletsCountRequest $set_shipment_pallets_count_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['setShipmentPalletsCount'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function setShipmentPalletsCountRequest($campaign_id, $shipment_id, $set_shipment_pallets_count_request, string $contentType = self::contentTypes['setShipmentPalletsCount'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling setShipmentPalletsCount' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.setShipmentPalletsCount, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling setShipmentPalletsCount' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.setShipmentPalletsCount, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'set_shipment_pallets_count_request' is set + if ($set_shipment_pallets_count_request === null || (is_array($set_shipment_pallets_count_request) && count($set_shipment_pallets_count_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $set_shipment_pallets_count_request when calling setShipmentPalletsCount' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/pallets'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($set_shipment_pallets_count_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($set_shipment_pallets_count_request)); + } else { + $httpBody = $set_shipment_pallets_count_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation transferOrdersFromShipment + * + * Перенос заказов в следующую отгрузку + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function transferOrdersFromShipment($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment'][0]) + { + list($response) = $this->transferOrdersFromShipmentWithHttpInfo($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, $contentType); + return $response; + } + + /** + * Operation transferOrdersFromShipmentWithHttpInfo + * + * Перенос заказов в следующую отгрузку + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function transferOrdersFromShipmentWithHttpInfo($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment'][0]) + { + $request = $this->transferOrdersFromShipmentRequest($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation transferOrdersFromShipmentAsync + * + * Перенос заказов в следующую отгрузку + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function transferOrdersFromShipmentAsync($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment'][0]) + { + return $this->transferOrdersFromShipmentAsyncWithHttpInfo($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation transferOrdersFromShipmentAsyncWithHttpInfo + * + * Перенос заказов в следующую отгрузку + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function transferOrdersFromShipmentAsyncWithHttpInfo($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->transferOrdersFromShipmentRequest($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'transferOrdersFromShipment' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param int $shipment_id Идентификатор отгрузки. (required) + * @param \OpenAPI\Client\Model\TransferOrdersFromShipmentRequest $transfer_orders_from_shipment_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['transferOrdersFromShipment'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function transferOrdersFromShipmentRequest($campaign_id, $shipment_id, $transfer_orders_from_shipment_request, string $contentType = self::contentTypes['transferOrdersFromShipment'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling transferOrdersFromShipment' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling ShipmentsApi.transferOrdersFromShipment, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'shipment_id' is set + if ($shipment_id === null || (is_array($shipment_id) && count($shipment_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $shipment_id when calling transferOrdersFromShipment' + ); + } + if ($shipment_id < 1) { + throw new \InvalidArgumentException('invalid value for "$shipment_id" when calling ShipmentsApi.transferOrdersFromShipment, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'transfer_orders_from_shipment_request' is set + if ($transfer_orders_from_shipment_request === null || (is_array($transfer_orders_from_shipment_request) && count($transfer_orders_from_shipment_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $transfer_orders_from_shipment_request when calling transferOrdersFromShipment' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/first-mile/shipments/{shipmentId}/orders/transfer'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + // path params + if ($shipment_id !== null) { + $resourcePath = str_replace( + '{' . 'shipmentId' . '}', + ObjectSerializer::toPathValue($shipment_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($transfer_orders_from_shipment_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($transfer_orders_from_shipment_request)); + } else { + $httpBody = $transfer_orders_from_shipment_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/StocksApi.php b/erp24/lib/yandex_market_api/Api/StocksApi.php new file mode 100644 index 00000000..ed1c5b27 --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/StocksApi.php @@ -0,0 +1,1233 @@ + [ + 'application/json', + ], + 'updateStocks' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getStocks + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getStocks($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks'][0]) + { + list($response) = $this->getStocksWithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + return $response; + } + + /** + * Operation getStocksWithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehouseStocksResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getStocksWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks'][0]) + { + $request = $this->getStocksRequest($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehouseStocksResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehouseStocksResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehouseStocksResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getStocksAsync + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocksAsync($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks'][0]) + { + return $this->getStocksAsyncWithHttpInfo($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getStocksAsyncWithHttpInfo + * + * Информация об остатках и оборачиваемости + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getStocksAsyncWithHttpInfo($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehouseStocksResponse'; + $request = $this->getStocksRequest($campaign_id, $page_token, $limit, $get_warehouse_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getStocks' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $page_token Идентификатор страницы c результатами. Если параметр не указан, возвращается первая страница. Рекомендуется передавать значение выходного параметра `nextPageToken`, полученное при последнем запросе. Если задан `page_token` и в запросе есть параметры `offset`, `page_number` и `page_size`, они игнорируются. (optional) + * @param int $limit Количество значений на одной странице. (optional) + * @param \OpenAPI\Client\Model\GetWarehouseStocksRequest $get_warehouse_stocks_request (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getStocks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getStocksRequest($campaign_id, $page_token = null, $limit = null, $get_warehouse_stocks_request = null, string $contentType = self::contentTypes['getStocks'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling getStocks' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling StocksApi.getStocks, must be bigger than or equal to 1.'); + } + + + + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $page_token, + 'page_token', // param base name + 'string', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $limit, + 'limit', // param base name + 'integer', // openApiType + '', // style + false, // explode + false // required + ) ?? []); + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($get_warehouse_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($get_warehouse_stocks_request)); + } else { + $httpBody = $get_warehouse_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updateStocks + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function updateStocks($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks'][0]) + { + list($response) = $this->updateStocksWithHttpInfo($campaign_id, $update_stocks_request, $contentType); + return $response; + } + + /** + * Operation updateStocksWithHttpInfo + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\EmptyApiResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function updateStocksWithHttpInfo($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks'][0]) + { + $request = $this->updateStocksRequest($campaign_id, $update_stocks_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\EmptyApiResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\EmptyApiResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\EmptyApiResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\EmptyApiResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation updateStocksAsync + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateStocksAsync($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks'][0]) + { + return $this->updateStocksAsyncWithHttpInfo($campaign_id, $update_stocks_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updateStocksAsyncWithHttpInfo + * + * Передача информации об остатках + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateStocksAsyncWithHttpInfo($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks'][0]) + { + $returnType = '\OpenAPI\Client\Model\EmptyApiResponse'; + $request = $this->updateStocksRequest($campaign_id, $update_stocks_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updateStocks' + * + * @param int $campaign_id Идентификатор кампании в API и магазина в кабинете. Каждая кампания в API соответствует магазину в кабинете. Чтобы узнать идентификаторы своих магазинов, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param \OpenAPI\Client\Model\UpdateStocksRequest $update_stocks_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateStocks'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function updateStocksRequest($campaign_id, $update_stocks_request, string $contentType = self::contentTypes['updateStocks'][0]) + { + + // verify the required parameter 'campaign_id' is set + if ($campaign_id === null || (is_array($campaign_id) && count($campaign_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $campaign_id when calling updateStocks' + ); + } + if ($campaign_id < 1) { + throw new \InvalidArgumentException('invalid value for "$campaign_id" when calling StocksApi.updateStocks, must be bigger than or equal to 1.'); + } + + // verify the required parameter 'update_stocks_request' is set + if ($update_stocks_request === null || (is_array($update_stocks_request) && count($update_stocks_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $update_stocks_request when calling updateStocks' + ); + } + + + $resourcePath = '/campaigns/{campaignId}/offers/stocks'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($campaign_id !== null) { + $resourcePath = str_replace( + '{' . 'campaignId' . '}', + ObjectSerializer::toPathValue($campaign_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($update_stocks_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($update_stocks_request)); + } else { + $httpBody = $update_stocks_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'PUT', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/TariffsApi.php b/erp24/lib/yandex_market_api/Api/TariffsApi.php new file mode 100644 index 00000000..42c1700f --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/TariffsApi.php @@ -0,0 +1,669 @@ + [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation calculateTariffs + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function calculateTariffs($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs'][0]) + { + list($response) = $this->calculateTariffsWithHttpInfo($calculate_tariffs_request, $contentType); + return $response; + } + + /** + * Operation calculateTariffsWithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CalculateTariffsResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function calculateTariffsWithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs'][0]) + { + $request = $this->calculateTariffsRequest($calculate_tariffs_request, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CalculateTariffsResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CalculateTariffsResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CalculateTariffsResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation calculateTariffsAsync + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffsAsync($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs'][0]) + { + return $this->calculateTariffsAsyncWithHttpInfo($calculate_tariffs_request, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation calculateTariffsAsyncWithHttpInfo + * + * Калькулятор стоимости услуг + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function calculateTariffsAsyncWithHttpInfo($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs'][0]) + { + $returnType = '\OpenAPI\Client\Model\CalculateTariffsResponse'; + $request = $this->calculateTariffsRequest($calculate_tariffs_request, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'calculateTariffs' + * + * @param \OpenAPI\Client\Model\CalculateTariffsRequest $calculate_tariffs_request (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['calculateTariffs'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function calculateTariffsRequest($calculate_tariffs_request, string $contentType = self::contentTypes['calculateTariffs'][0]) + { + + // verify the required parameter 'calculate_tariffs_request' is set + if ($calculate_tariffs_request === null || (is_array($calculate_tariffs_request) && count($calculate_tariffs_request) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $calculate_tariffs_request when calling calculateTariffs' + ); + } + + + $resourcePath = '/tariffs/calculate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($calculate_tariffs_request)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($calculate_tariffs_request)); + } else { + $httpBody = $calculate_tariffs_request; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/Api/WarehousesApi.php b/erp24/lib/yandex_market_api/Api/WarehousesApi.php new file mode 100644 index 00000000..055293bc --- /dev/null +++ b/erp24/lib/yandex_market_api/Api/WarehousesApi.php @@ -0,0 +1,1183 @@ + [ + 'application/json', + ], + 'getWarehouses' => [ + 'application/json', + ], + ]; + + /** + * @param ClientInterface $client + * @param Configuration $config + * @param HeaderSelector $selector + * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec + */ + public function __construct( + ClientInterface $client = null, + Configuration $config = null, + HeaderSelector $selector = null, + $hostIndex = 0 + ) { + $this->client = $client ?: new Client(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $hostIndex; + } + + /** + * Set the host index + * + * @param int $hostIndex Host index (required) + */ + public function setHostIndex($hostIndex): void + { + $this->hostIndex = $hostIndex; + } + + /** + * Get the host index + * + * @return int Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getFulfillmentWarehouses + * + * Идентификаторы складов Маркета (FBY) + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetFulfillmentWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getFulfillmentWarehouses(string $contentType = self::contentTypes['getFulfillmentWarehouses'][0]) + { + list($response) = $this->getFulfillmentWarehousesWithHttpInfo($contentType); + return $response; + } + + /** + * Operation getFulfillmentWarehousesWithHttpInfo + * + * Идентификаторы складов Маркета (FBY) + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetFulfillmentWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getFulfillmentWarehousesWithHttpInfo(string $contentType = self::contentTypes['getFulfillmentWarehouses'][0]) + { + $request = $this->getFulfillmentWarehousesRequest($contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getFulfillmentWarehousesAsync + * + * Идентификаторы складов Маркета (FBY) + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getFulfillmentWarehousesAsync(string $contentType = self::contentTypes['getFulfillmentWarehouses'][0]) + { + return $this->getFulfillmentWarehousesAsyncWithHttpInfo($contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getFulfillmentWarehousesAsyncWithHttpInfo + * + * Идентификаторы складов Маркета (FBY) + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getFulfillmentWarehousesAsyncWithHttpInfo(string $contentType = self::contentTypes['getFulfillmentWarehouses'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetFulfillmentWarehousesResponse'; + $request = $this->getFulfillmentWarehousesRequest($contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getFulfillmentWarehouses' + * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getFulfillmentWarehouses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getFulfillmentWarehousesRequest(string $contentType = self::contentTypes['getFulfillmentWarehouses'][0]) + { + + + $resourcePath = '/warehouses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getWarehouses + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\GetWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse + */ + public function getWarehouses($business_id, string $contentType = self::contentTypes['getWarehouses'][0]) + { + list($response) = $this->getWarehousesWithHttpInfo($business_id, $contentType); + return $response; + } + + /** + * Operation getWarehousesWithHttpInfo + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\GetWarehousesResponse|\OpenAPI\Client\Model\ApiClientDataErrorResponse|\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse|\OpenAPI\Client\Model\ApiForbiddenErrorResponse|\OpenAPI\Client\Model\ApiNotFoundErrorResponse|\OpenAPI\Client\Model\ApiLimitErrorResponse|\OpenAPI\Client\Model\ApiServerErrorResponse, HTTP status code, HTTP response headers (array of strings) + */ + public function getWarehousesWithHttpInfo($business_id, string $contentType = self::contentTypes['getWarehouses'][0]) + { + $request = $this->getWarehousesRequest($business_id, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\GetWarehousesResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\GetWarehousesResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\GetWarehousesResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 400: + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiClientDataErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiClientDataErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 401: + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 403: + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiForbiddenErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 404: + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiNotFoundErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 420: + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiLimitErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiLimitErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 500: + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\ApiServerErrorResponse' !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiServerErrorResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + $returnType = '\OpenAPI\Client\Model\GetWarehousesResponse'; + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\GetWarehousesResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiClientDataErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiUnauthorizedErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 403: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiForbiddenErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiNotFoundErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 420: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiLimitErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 500: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\ApiServerErrorResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getWarehousesAsync + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getWarehousesAsync($business_id, string $contentType = self::contentTypes['getWarehouses'][0]) + { + return $this->getWarehousesAsyncWithHttpInfo($business_id, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getWarehousesAsyncWithHttpInfo + * + * Список складов и групп складов + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getWarehousesAsyncWithHttpInfo($business_id, string $contentType = self::contentTypes['getWarehouses'][0]) + { + $returnType = '\OpenAPI\Client\Model\GetWarehousesResponse'; + $request = $this->getWarehousesRequest($business_id, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getWarehouses' + * + * @param int $business_id Идентификатор кабинета. Чтобы узнать идентификатор, воспользуйтесь запросом [GET campaigns](../../reference/campaigns/getCampaigns.md#businessdto). ℹ️ [Что такое кабинет и магазин на Маркете](https://yandex.ru/support/marketplace/account/introduction.html) (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getWarehouses'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getWarehousesRequest($business_id, string $contentType = self::contentTypes['getWarehouses'][0]) + { + + // verify the required parameter 'business_id' is set + if ($business_id === null || (is_array($business_id) && count($business_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $business_id when calling getWarehouses' + ); + } + if ($business_id < 1) { + throw new \InvalidArgumentException('invalid value for "$business_id" when calling WarehousesApi.getWarehouses, must be bigger than or equal to 1.'); + } + + + $resourcePath = '/businesses/{businessId}/warehouses'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($business_id !== null) { + $resourcePath = str_replace( + '{' . 'businessId' . '}', + ObjectSerializer::toPathValue($business_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Api-Key'); + if ($apiKey !== null) { + $headers['Api-Key'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/erp24/lib/yandex_market_api/ApiException.php b/erp24/lib/yandex_market_api/ApiException.php new file mode 100644 index 00000000..d9d1f974 --- /dev/null +++ b/erp24/lib/yandex_market_api/ApiException.php @@ -0,0 +1,119 @@ +responseHeaders = $responseHeaders; + $this->responseBody = $responseBody; + } + + /** + * Gets the HTTP response header + * + * @return string[][]|null HTTP response header + */ + public function getResponseHeaders() + { + return $this->responseHeaders; + } + + /** + * Gets the HTTP body of the server response either as Json or string + * + * @return \stdClass|string|null HTTP body of the server response either as \stdClass or string + */ + public function getResponseBody() + { + return $this->responseBody; + } + + /** + * Sets the deserialized response object (during deserialization) + * + * @param mixed $obj Deserialized response object + * + * @return void + */ + public function setResponseObject($obj) + { + $this->responseObject = $obj; + } + + /** + * Gets the deserialized response object (during deserialization) + * + * @return mixed the deserialized response object + */ + public function getResponseObject() + { + return $this->responseObject; + } +} diff --git a/erp24/lib/yandex_market_api/Configuration.php b/erp24/lib/yandex_market_api/Configuration.php new file mode 100644 index 00000000..3f3bb064 --- /dev/null +++ b/erp24/lib/yandex_market_api/Configuration.php @@ -0,0 +1,531 @@ +tempFolderPath = sys_get_temp_dir(); + } + + /** + * Sets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $key API key or token + * + * @return $this + */ + public function setApiKey($apiKeyIdentifier, $key) + { + $this->apiKeys[$apiKeyIdentifier] = $key; + return $this; + } + + /** + * Gets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return null|string API key or token + */ + public function getApiKey($apiKeyIdentifier) + { + return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; + } + + /** + * Sets the prefix for API key (e.g. Bearer) + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $prefix API key prefix, e.g. Bearer + * + * @return $this + */ + public function setApiKeyPrefix($apiKeyIdentifier, $prefix) + { + $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; + return $this; + } + + /** + * Gets API key prefix + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return null|string + */ + public function getApiKeyPrefix($apiKeyIdentifier) + { + return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; + } + + /** + * Sets the access token for OAuth + * + * @param string $accessToken Token for OAuth + * + * @return $this + */ + public function setAccessToken($accessToken) + { + $this->accessToken = $accessToken; + return $this; + } + + /** + * Gets the access token for OAuth + * + * @return string Access token for OAuth + */ + public function getAccessToken() + { + return $this->accessToken; + } + + /** + * Sets boolean format for query string. + * + * @param string $booleanFormat Boolean format for query string + * + * @return $this + */ + public function setBooleanFormatForQueryString(string $booleanFormat) + { + $this->booleanFormatForQueryString = $booleanFormat; + + return $this; + } + + /** + * Gets boolean format for query string. + * + * @return string Boolean format for query string + */ + public function getBooleanFormatForQueryString(): string + { + return $this->booleanFormatForQueryString; + } + + /** + * Sets the username for HTTP basic authentication + * + * @param string $username Username for HTTP basic authentication + * + * @return $this + */ + public function setUsername($username) + { + $this->username = $username; + return $this; + } + + /** + * Gets the username for HTTP basic authentication + * + * @return string Username for HTTP basic authentication + */ + public function getUsername() + { + return $this->username; + } + + /** + * Sets the password for HTTP basic authentication + * + * @param string $password Password for HTTP basic authentication + * + * @return $this + */ + public function setPassword($password) + { + $this->password = $password; + return $this; + } + + /** + * Gets the password for HTTP basic authentication + * + * @return string Password for HTTP basic authentication + */ + public function getPassword() + { + return $this->password; + } + + /** + * Sets the host + * + * @param string $host Host + * + * @return $this + */ + public function setHost($host) + { + $this->host = $host; + return $this; + } + + /** + * Gets the host + * + * @return string Host + */ + public function getHost() + { + return $this->host; + } + + /** + * Sets the user agent of the api client + * + * @param string $userAgent the user agent of the api client + * + * @throws \InvalidArgumentException + * @return $this + */ + public function setUserAgent($userAgent) + { + if (!is_string($userAgent)) { + throw new \InvalidArgumentException('User-agent must be a string.'); + } + + $this->userAgent = $userAgent; + return $this; + } + + /** + * Gets the user agent of the api client + * + * @return string user agent + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * Sets debug flag + * + * @param bool $debug Debug flag + * + * @return $this + */ + public function setDebug($debug) + { + $this->debug = $debug; + return $this; + } + + /** + * Gets the debug flag + * + * @return bool + */ + public function getDebug() + { + return $this->debug; + } + + /** + * Sets the debug file + * + * @param string $debugFile Debug file + * + * @return $this + */ + public function setDebugFile($debugFile) + { + $this->debugFile = $debugFile; + return $this; + } + + /** + * Gets the debug file + * + * @return string + */ + public function getDebugFile() + { + return $this->debugFile; + } + + /** + * Sets the temp folder path + * + * @param string $tempFolderPath Temp folder path + * + * @return $this + */ + public function setTempFolderPath($tempFolderPath) + { + $this->tempFolderPath = $tempFolderPath; + return $this; + } + + /** + * Gets the temp folder path + * + * @return string Temp folder path + */ + public function getTempFolderPath() + { + return $this->tempFolderPath; + } + + /** + * Gets the default configuration instance + * + * @return Configuration + */ + public static function getDefaultConfiguration() + { + if (self::$defaultConfiguration === null) { + self::$defaultConfiguration = new Configuration(); + } + + return self::$defaultConfiguration; + } + + /** + * Sets the default configuration instance + * + * @param Configuration $config An instance of the Configuration Object + * + * @return void + */ + public static function setDefaultConfiguration(Configuration $config) + { + self::$defaultConfiguration = $config; + } + + /** + * Gets the essential information for debugging + * + * @return string The report for debugging + */ + public static function toDebugReport() + { + $report = 'PHP SDK (OpenAPI\Client) Debug Report:' . PHP_EOL; + $report .= ' OS: ' . php_uname() . PHP_EOL; + $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; + $report .= ' The version of the OpenAPI document: LATEST' . PHP_EOL; + $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; + + return $report; + } + + /** + * Get API key (with prefix if set) + * + * @param string $apiKeyIdentifier name of apikey + * + * @return null|string API key with the prefix + */ + public function getApiKeyWithPrefix($apiKeyIdentifier) + { + $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->getApiKey($apiKeyIdentifier); + + if ($apiKey === null) { + return null; + } + + if ($prefix === null) { + $keyWithPrefix = $apiKey; + } else { + $keyWithPrefix = $prefix . ' ' . $apiKey; + } + + return $keyWithPrefix; + } + + /** + * Returns an array of host settings + * + * @return array an array of host settings + */ + public function getHostSettings() + { + return [ + [ + "url" => "https://api.partner.market.yandex.ru", + "description" => "No description provided", + ] + ]; + } + + /** + * Returns URL based on host settings, index and variables + * + * @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients + * @param int $hostIndex index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings + */ + public static function getHostString(array $hostSettings, $hostIndex, array $variables = null) + { + if (null === $variables) { + $variables = []; + } + + // check array index out of bound + if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { + throw new \InvalidArgumentException("Invalid index $hostIndex when selecting the host. Must be less than ".count($hostSettings)); + } + + $host = $hostSettings[$hostIndex]; + $url = $host["url"]; + + // go through variable and assign a value + foreach ($host["variables"] ?? [] as $name => $variable) { + if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user + if (!isset($variable['enum_values']) || in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum + $url = str_replace("{".$name."}", $variables[$name], $url); + } else { + throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"])."."); + } + } else { + // use default value + $url = str_replace("{".$name."}", $variable["default_value"], $url); + } + } + + return $url; + } + + /** + * Returns URL based on the index and variables + * + * @param int $index index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings + */ + public function getHostFromSettings($index, $variables = null) + { + return self::getHostString($this->getHostSettings(), $index, $variables); + } +} diff --git a/erp24/lib/yandex_market_api/HeaderSelector.php b/erp24/lib/yandex_market_api/HeaderSelector.php new file mode 100644 index 00000000..f4ef0012 --- /dev/null +++ b/erp24/lib/yandex_market_api/HeaderSelector.php @@ -0,0 +1,273 @@ +selectAcceptHeader($accept); + if ($accept !== null) { + $headers['Accept'] = $accept; + } + + if (!$isMultipart) { + if($contentType === '') { + $contentType = 'application/json'; + } + + $headers['Content-Type'] = $contentType; + } + + return $headers; + } + + /** + * Return the header 'Accept' based on an array of Accept provided. + * + * @param string[] $accept Array of header + * + * @return null|string Accept (e.g. application/json) + */ + private function selectAcceptHeader(array $accept): ?string + { + # filter out empty entries + $accept = array_filter($accept); + + if (count($accept) === 0) { + return null; + } + + # If there's only one Accept header, just use it + if (count($accept) === 1) { + return reset($accept); + } + + # If none of the available Accept headers is of type "json", then just use all them + $headersWithJson = $this->selectJsonMimeList($accept); + if (count($headersWithJson) === 0) { + return implode(',', $accept); + } + + # If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1, + # to give the highest priority to json-like headers - recalculating the existing ones, if needed + return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson); + } + + /** + * Detects whether a string contains a valid JSON mime type + * + * @param string $searchString + * @return bool + */ + public function isJsonMime(string $searchString): bool + { + return preg_match('~^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)~', $searchString) === 1; + } + + /** + * Select all items from a list containing a JSON mime type + * + * @param array $mimeList + * @return array + */ + private function selectJsonMimeList(array $mimeList): array { + $jsonMimeList = []; + foreach ($mimeList as $mime) { + if($this->isJsonMime($mime)) { + $jsonMimeList[] = $mime; + } + } + return $jsonMimeList; + } + + + /** + * Create an Accept header string from the given "Accept" headers array, recalculating all weights + * + * @param string[] $accept Array of Accept Headers + * @param string[] $headersWithJson Array of Accept Headers of type "json" + * + * @return string "Accept" Header (e.g. "application/json, text/html; q=0.9") + */ + private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string + { + $processedHeaders = [ + 'withApplicationJson' => [], + 'withJson' => [], + 'withoutJson' => [], + ]; + + foreach ($accept as $header) { + + $headerData = $this->getHeaderAndWeight($header); + + if (stripos($headerData['header'], 'application/json') === 0) { + $processedHeaders['withApplicationJson'][] = $headerData; + } elseif (in_array($header, $headersWithJson, true)) { + $processedHeaders['withJson'][] = $headerData; + } else { + $processedHeaders['withoutJson'][] = $headerData; + } + } + + $acceptHeaders = []; + $currentWeight = 1000; + + $hasMoreThan28Headers = count($accept) > 28; + + foreach($processedHeaders as $headers) { + if (count($headers) > 0) { + $acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers); + } + } + + $acceptHeaders = array_merge(...$acceptHeaders); + + return implode(',', $acceptHeaders); + } + + /** + * Given an Accept header, returns an associative array splitting the header and its weight + * + * @param string $header "Accept" Header + * + * @return array with the header and its weight + */ + private function getHeaderAndWeight(string $header): array + { + # matches headers with weight, splitting the header and the weight in $outputArray + if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) { + $headerData = [ + 'header' => $outputArray[1], + 'weight' => (int)($outputArray[2] * 1000), + ]; + } else { + $headerData = [ + 'header' => trim($header), + 'weight' => 1000, + ]; + } + + return $headerData; + } + + /** + * @param array[] $headers + * @param float $currentWeight + * @param bool $hasMoreThan28Headers + * @return string[] array of adjusted "Accept" headers + */ + private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array + { + usort($headers, function (array $a, array $b) { + return $b['weight'] - $a['weight']; + }); + + $acceptHeaders = []; + foreach ($headers as $index => $header) { + if($index > 0 && $headers[$index - 1]['weight'] > $header['weight']) + { + $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); + } + + $weight = $currentWeight; + + $acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight); + } + + $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); + + return $acceptHeaders; + } + + /** + * @param string $header + * @param int $weight + * @return string + */ + private function buildAcceptHeader(string $header, int $weight): string + { + if($weight === 1000) { + return $header; + } + + return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0'); + } + + /** + * Calculate the next weight, based on the current one. + * + * If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the + * following formula: + * + * next weight = current weight - 10 ^ (floor(log(current weight - 1))) + * + * ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) ) + * + * Starting from 1000, this generates the following series: + * + * 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 + * + * The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works + * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 + * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. + * + * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) + * @param bool $hasMoreThan28Headers + * @return int + */ + public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int + { + if ($currentWeight <= 1) { + return 1; + } + + if ($hasMoreThan28Headers) { + return $currentWeight - 1; + } + + return $currentWeight - 10 ** floor( log10($currentWeight - 1) ); + } +} diff --git a/erp24/lib/yandex_market_api/Model/AcceptOrderCancellationRequest.php b/erp24/lib/yandex_market_api/Model/AcceptOrderCancellationRequest.php new file mode 100644 index 00000000..cddb193a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/AcceptOrderCancellationRequest.php @@ -0,0 +1,446 @@ + + */ +class AcceptOrderCancellationRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AcceptOrderCancellationRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'accepted' => 'bool', + 'reason' => '\OpenAPI\Client\Model\OrderCancellationReasonType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'accepted' => null, + 'reason' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'accepted' => false, + 'reason' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'accepted' => 'accepted', + 'reason' => 'reason' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'accepted' => 'setAccepted', + 'reason' => 'setReason' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'accepted' => 'getAccepted', + 'reason' => 'getReason' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('accepted', $data ?? [], null); + $this->setIfExists('reason', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['accepted'] === null) { + $invalidProperties[] = "'accepted' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets accepted + * + * @return bool + */ + public function getAccepted() + { + return $this->container['accepted']; + } + + /** + * Sets accepted + * + * @param bool $accepted Решение об отмене заказа: * `true` — заказ отменяется, служба доставки узнала об отмене до передачи заказа покупателю. * `false` — заказ не отменяется, так как он уже доставлен покупателю курьером или передан в пункт выдачи заказов. + * + * @return self + */ + public function setAccepted($accepted) + { + if (is_null($accepted)) { + throw new \InvalidArgumentException('non-nullable accepted cannot be null'); + } + $this->container['accepted'] = $accepted; + + return $this; + } + + /** + * Gets reason + * + * @return \OpenAPI\Client\Model\OrderCancellationReasonType|null + */ + public function getReason() + { + return $this->container['reason']; + } + + /** + * Sets reason + * + * @param \OpenAPI\Client\Model\OrderCancellationReasonType|null $reason reason + * + * @return self + */ + public function setReason($reason) + { + if (is_null($reason)) { + throw new \InvalidArgumentException('non-nullable reason cannot be null'); + } + $this->container['reason'] = $reason; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/AddHiddenOffersRequest.php b/erp24/lib/yandex_market_api/Model/AddHiddenOffersRequest.php new file mode 100644 index 00000000..59791cae --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/AddHiddenOffersRequest.php @@ -0,0 +1,428 @@ + + */ +class AddHiddenOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AddHiddenOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'hidden_offers' => '\OpenAPI\Client\Model\HiddenOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'hidden_offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'hidden_offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'hidden_offers' => 'hiddenOffers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'hidden_offers' => 'setHiddenOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'hidden_offers' => 'getHiddenOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('hidden_offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['hidden_offers'] === null) { + $invalidProperties[] = "'hidden_offers' can't be null"; + } + if ((count($this->container['hidden_offers']) > 500)) { + $invalidProperties[] = "invalid value for 'hidden_offers', number of items must be less than or equal to 500."; + } + + if ((count($this->container['hidden_offers']) < 1)) { + $invalidProperties[] = "invalid value for 'hidden_offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets hidden_offers + * + * @return \OpenAPI\Client\Model\HiddenOfferDTO[] + */ + public function getHiddenOffers() + { + return $this->container['hidden_offers']; + } + + /** + * Sets hidden_offers + * + * @param \OpenAPI\Client\Model\HiddenOfferDTO[] $hidden_offers Список скрытых товаров. + * + * @return self + */ + public function setHiddenOffers($hidden_offers) + { + if (is_null($hidden_offers)) { + throw new \InvalidArgumentException('non-nullable hidden_offers cannot be null'); + } + + if ((count($hidden_offers) > 500)) { + throw new \InvalidArgumentException('invalid value for $hidden_offers when calling AddHiddenOffersRequest., number of items must be less than or equal to 500.'); + } + if ((count($hidden_offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $hidden_offers when calling AddHiddenOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['hidden_offers'] = $hidden_offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/AddOffersToArchiveDTO.php b/erp24/lib/yandex_market_api/Model/AddOffersToArchiveDTO.php new file mode 100644 index 00000000..7fe4bc36 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/AddOffersToArchiveDTO.php @@ -0,0 +1,417 @@ + + */ +class AddOffersToArchiveDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AddOffersToArchiveDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'not_archived_offers' => '\OpenAPI\Client\Model\AddOffersToArchiveErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'not_archived_offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'not_archived_offers' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'not_archived_offers' => 'notArchivedOffers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'not_archived_offers' => 'setNotArchivedOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'not_archived_offers' => 'getNotArchivedOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('not_archived_offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets not_archived_offers + * + * @return \OpenAPI\Client\Model\AddOffersToArchiveErrorDTO[]|null + */ + public function getNotArchivedOffers() + { + return $this->container['not_archived_offers']; + } + + /** + * Sets not_archived_offers + * + * @param \OpenAPI\Client\Model\AddOffersToArchiveErrorDTO[]|null $not_archived_offers Список товаров, которые не удалось поместить в архив. + * + * @return self + */ + public function setNotArchivedOffers($not_archived_offers) + { + if (is_null($not_archived_offers)) { + array_push($this->openAPINullablesSetToNull, 'not_archived_offers'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('not_archived_offers', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['not_archived_offers'] = $not_archived_offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/AddOffersToArchiveErrorDTO.php b/erp24/lib/yandex_market_api/Model/AddOffersToArchiveErrorDTO.php new file mode 100644 index 00000000..fc4da560 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/AddOffersToArchiveErrorDTO.php @@ -0,0 +1,472 @@ + + */ +class AddOffersToArchiveErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AddOffersToArchiveErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'error' => '\OpenAPI\Client\Model\AddOffersToArchiveErrorType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'error' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'error' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'error' => 'error' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'error' => 'setError' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'error' => 'getError' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('error', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['error'] === null) { + $invalidProperties[] = "'error' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling AddOffersToArchiveErrorDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling AddOffersToArchiveErrorDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling AddOffersToArchiveErrorDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets error + * + * @return \OpenAPI\Client\Model\AddOffersToArchiveErrorType + */ + public function getError() + { + return $this->container['error']; + } + + /** + * Sets error + * + * @param \OpenAPI\Client\Model\AddOffersToArchiveErrorType $error error + * + * @return self + */ + public function setError($error) + { + if (is_null($error)) { + throw new \InvalidArgumentException('non-nullable error cannot be null'); + } + $this->container['error'] = $error; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/AddOffersToArchiveErrorType.php b/erp24/lib/yandex_market_api/Model/AddOffersToArchiveErrorType.php new file mode 100644 index 00000000..121dd3cd --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/AddOffersToArchiveErrorType.php @@ -0,0 +1,63 @@ + + */ +class AddOffersToArchiveRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AddOffersToArchiveRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_ids'] === null) { + $invalidProperties[] = "'offer_ids' can't be null"; + } + if ((count($this->container['offer_ids']) > 200)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 200."; + } + + if ((count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[] + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[] $offer_ids Список товаров, которые нужно поместить в архив. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + throw new \InvalidArgumentException('non-nullable offer_ids cannot be null'); + } + + if ((count($offer_ids) > 200)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling AddOffersToArchiveRequest., number of items must be less than or equal to 200.'); + } + if ((count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling AddOffersToArchiveRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/AddOffersToArchiveResponse.php b/erp24/lib/yandex_market_api/Model/AddOffersToArchiveResponse.php new file mode 100644 index 00000000..3fbef7fe --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/AddOffersToArchiveResponse.php @@ -0,0 +1,444 @@ + + */ +class AddOffersToArchiveResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AddOffersToArchiveResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\AddOffersToArchiveDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\AddOffersToArchiveDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\AddOffersToArchiveDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/AffectedOrderQualityRatingComponentType.php b/erp24/lib/yandex_market_api/Model/AffectedOrderQualityRatingComponentType.php new file mode 100644 index 00000000..8daf2afd --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/AffectedOrderQualityRatingComponentType.php @@ -0,0 +1,69 @@ + + */ +class AgeDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'AgeDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'float', + 'age_unit' => '\OpenAPI\Client\Model\AgeUnitType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'age_unit' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'value' => false, + 'age_unit' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'age_unit' => 'ageUnit' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'age_unit' => 'setAgeUnit' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'age_unit' => 'getAgeUnit' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('age_unit', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if (($this->container['value'] < 0)) { + $invalidProperties[] = "invalid value for 'value', must be bigger than or equal to 0."; + } + + if ($this->container['age_unit'] === null) { + $invalidProperties[] = "'age_unit' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return float + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param float $value Значение. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + + if (($value < 0)) { + throw new \InvalidArgumentException('invalid value for $value when calling AgeDTO., must be bigger than or equal to 0.'); + } + + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets age_unit + * + * @return \OpenAPI\Client\Model\AgeUnitType + */ + public function getAgeUnit() + { + return $this->container['age_unit']; + } + + /** + * Sets age_unit + * + * @param \OpenAPI\Client\Model\AgeUnitType $age_unit age_unit + * + * @return self + */ + public function setAgeUnit($age_unit) + { + if (is_null($age_unit)) { + throw new \InvalidArgumentException('non-nullable age_unit cannot be null'); + } + $this->container['age_unit'] = $age_unit; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/AgeUnitType.php b/erp24/lib/yandex_market_api/Model/AgeUnitType.php new file mode 100644 index 00000000..851f143f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/AgeUnitType.php @@ -0,0 +1,63 @@ + + */ +class ApiClientDataErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiClientDataErrorResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'errors' => '\OpenAPI\Client\Model\ApiErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\ApiErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\ApiErrorDTO[]|null $errors Список ошибок. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiErrorDTO.php b/erp24/lib/yandex_market_api/Model/ApiErrorDTO.php new file mode 100644 index 00000000..35c985e8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiErrorDTO.php @@ -0,0 +1,447 @@ + + */ +class ApiErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'code' => 'string', + 'message' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'code' => null, + 'message' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'code' => false, + 'message' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'code' => 'code', + 'message' => 'message' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'code' => 'setCode', + 'message' => 'setMessage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'code' => 'getCode', + 'message' => 'getMessage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('code', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['code'] === null) { + $invalidProperties[] = "'code' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets code + * + * @return string + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string $code Код ошибки. + * + * @return self + */ + public function setCode($code) + { + if (is_null($code)) { + throw new \InvalidArgumentException('non-nullable code cannot be null'); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Описание ошибки. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiErrorResponse.php b/erp24/lib/yandex_market_api/Model/ApiErrorResponse.php new file mode 100644 index 00000000..81004576 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiErrorResponse.php @@ -0,0 +1,451 @@ + + */ +class ApiErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiErrorResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'errors' => '\OpenAPI\Client\Model\ApiErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\ApiErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\ApiErrorDTO[]|null $errors Список ошибок. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiForbiddenErrorResponse.php b/erp24/lib/yandex_market_api/Model/ApiForbiddenErrorResponse.php new file mode 100644 index 00000000..1637ef0d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiForbiddenErrorResponse.php @@ -0,0 +1,451 @@ + + */ +class ApiForbiddenErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiForbiddenErrorResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'errors' => '\OpenAPI\Client\Model\ApiErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\ApiErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\ApiErrorDTO[]|null $errors Список ошибок. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiLimitErrorResponse.php b/erp24/lib/yandex_market_api/Model/ApiLimitErrorResponse.php new file mode 100644 index 00000000..6a7bfe1d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiLimitErrorResponse.php @@ -0,0 +1,451 @@ + + */ +class ApiLimitErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiLimitErrorResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'errors' => '\OpenAPI\Client\Model\ApiErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\ApiErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\ApiErrorDTO[]|null $errors Список ошибок. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiLockedErrorResponse.php b/erp24/lib/yandex_market_api/Model/ApiLockedErrorResponse.php new file mode 100644 index 00000000..92792094 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiLockedErrorResponse.php @@ -0,0 +1,451 @@ + + */ +class ApiLockedErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiLockedErrorResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'errors' => '\OpenAPI\Client\Model\ApiErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\ApiErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\ApiErrorDTO[]|null $errors Список ошибок. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiNotFoundErrorResponse.php b/erp24/lib/yandex_market_api/Model/ApiNotFoundErrorResponse.php new file mode 100644 index 00000000..17b9a94a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiNotFoundErrorResponse.php @@ -0,0 +1,451 @@ + + */ +class ApiNotFoundErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiNotFoundErrorResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'errors' => '\OpenAPI\Client\Model\ApiErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\ApiErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\ApiErrorDTO[]|null $errors Список ошибок. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiResponse.php b/erp24/lib/yandex_market_api/Model/ApiResponse.php new file mode 100644 index 00000000..6f0899bf --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiResponse.php @@ -0,0 +1,410 @@ + + */ +class ApiResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiResponseStatusType.php b/erp24/lib/yandex_market_api/Model/ApiResponseStatusType.php new file mode 100644 index 00000000..cd41fe09 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiResponseStatusType.php @@ -0,0 +1,63 @@ + + */ +class ApiServerErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiServerErrorResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'errors' => '\OpenAPI\Client\Model\ApiErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\ApiErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\ApiErrorDTO[]|null $errors Список ошибок. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ApiUnauthorizedErrorResponse.php b/erp24/lib/yandex_market_api/Model/ApiUnauthorizedErrorResponse.php new file mode 100644 index 00000000..b310c10b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ApiUnauthorizedErrorResponse.php @@ -0,0 +1,451 @@ + + */ +class ApiUnauthorizedErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ApiUnauthorizedErrorResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'errors' => '\OpenAPI\Client\Model\ApiErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\ApiErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\ApiErrorDTO[]|null $errors Список ошибок. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BaseCampaignOfferDTO.php b/erp24/lib/yandex_market_api/Model/BaseCampaignOfferDTO.php new file mode 100644 index 00000000..525d00bf --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BaseCampaignOfferDTO.php @@ -0,0 +1,503 @@ + + */ +class BaseCampaignOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BaseCampaignOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'quantum' => '\OpenAPI\Client\Model\QuantumDTO', + 'available' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'quantum' => null, + 'available' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'quantum' => false, + 'available' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'quantum' => 'quantum', + 'available' => 'available' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'quantum' => 'setQuantum', + 'available' => 'setAvailable' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'quantum' => 'getQuantum', + 'available' => 'getAvailable' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('quantum', $data ?? [], null); + $this->setIfExists('available', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling BaseCampaignOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling BaseCampaignOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling BaseCampaignOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets quantum + * + * @return \OpenAPI\Client\Model\QuantumDTO|null + */ + public function getQuantum() + { + return $this->container['quantum']; + } + + /** + * Sets quantum + * + * @param \OpenAPI\Client\Model\QuantumDTO|null $quantum quantum + * + * @return self + */ + public function setQuantum($quantum) + { + if (is_null($quantum)) { + throw new \InvalidArgumentException('non-nullable quantum cannot be null'); + } + $this->container['quantum'] = $quantum; + + return $this; + } + + /** + * Gets available + * + * @return bool|null + */ + public function getAvailable() + { + return $this->container['available']; + } + + /** + * Sets available + * + * @param bool|null $available Есть ли товар в продаже. + * + * @return self + */ + public function setAvailable($available) + { + if (is_null($available)) { + throw new \InvalidArgumentException('non-nullable available cannot be null'); + } + $this->container['available'] = $available; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BaseOfferDTO.php b/erp24/lib/yandex_market_api/Model/BaseOfferDTO.php new file mode 100644 index 00000000..85d80cca --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BaseOfferDTO.php @@ -0,0 +1,1375 @@ + + */ +class BaseOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BaseOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'name' => 'string', + 'market_category_id' => 'int', + 'category' => 'string', + 'pictures' => 'string[]', + 'videos' => 'string[]', + 'manuals' => '\OpenAPI\Client\Model\OfferManualDTO[]', + 'vendor' => 'string', + 'barcodes' => 'string[]', + 'description' => 'string', + 'manufacturer_countries' => 'string[]', + 'weight_dimensions' => '\OpenAPI\Client\Model\OfferWeightDimensionsDTO', + 'vendor_code' => 'string', + 'tags' => 'string[]', + 'shelf_life' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'life_time' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'guarantee_period' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'customs_commodity_code' => 'string', + 'certificates' => 'string[]', + 'box_count' => 'int', + 'condition' => '\OpenAPI\Client\Model\OfferConditionDTO', + 'type' => '\OpenAPI\Client\Model\OfferType', + 'downloadable' => 'bool', + 'adult' => 'bool', + 'age' => '\OpenAPI\Client\Model\AgeDTO', + 'params' => '\OpenAPI\Client\Model\OfferParamDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'name' => null, + 'market_category_id' => 'int64', + 'category' => null, + 'pictures' => null, + 'videos' => null, + 'manuals' => null, + 'vendor' => null, + 'barcodes' => null, + 'description' => null, + 'manufacturer_countries' => null, + 'weight_dimensions' => null, + 'vendor_code' => null, + 'tags' => null, + 'shelf_life' => null, + 'life_time' => null, + 'guarantee_period' => null, + 'customs_commodity_code' => null, + 'certificates' => null, + 'box_count' => 'int32', + 'condition' => null, + 'type' => null, + 'downloadable' => null, + 'adult' => null, + 'age' => null, + 'params' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'name' => false, + 'market_category_id' => false, + 'category' => false, + 'pictures' => true, + 'videos' => true, + 'manuals' => true, + 'vendor' => false, + 'barcodes' => true, + 'description' => false, + 'manufacturer_countries' => true, + 'weight_dimensions' => false, + 'vendor_code' => false, + 'tags' => true, + 'shelf_life' => false, + 'life_time' => false, + 'guarantee_period' => false, + 'customs_commodity_code' => false, + 'certificates' => true, + 'box_count' => false, + 'condition' => false, + 'type' => false, + 'downloadable' => false, + 'adult' => false, + 'age' => false, + 'params' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'name' => 'name', + 'market_category_id' => 'marketCategoryId', + 'category' => 'category', + 'pictures' => 'pictures', + 'videos' => 'videos', + 'manuals' => 'manuals', + 'vendor' => 'vendor', + 'barcodes' => 'barcodes', + 'description' => 'description', + 'manufacturer_countries' => 'manufacturerCountries', + 'weight_dimensions' => 'weightDimensions', + 'vendor_code' => 'vendorCode', + 'tags' => 'tags', + 'shelf_life' => 'shelfLife', + 'life_time' => 'lifeTime', + 'guarantee_period' => 'guaranteePeriod', + 'customs_commodity_code' => 'customsCommodityCode', + 'certificates' => 'certificates', + 'box_count' => 'boxCount', + 'condition' => 'condition', + 'type' => 'type', + 'downloadable' => 'downloadable', + 'adult' => 'adult', + 'age' => 'age', + 'params' => 'params' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'name' => 'setName', + 'market_category_id' => 'setMarketCategoryId', + 'category' => 'setCategory', + 'pictures' => 'setPictures', + 'videos' => 'setVideos', + 'manuals' => 'setManuals', + 'vendor' => 'setVendor', + 'barcodes' => 'setBarcodes', + 'description' => 'setDescription', + 'manufacturer_countries' => 'setManufacturerCountries', + 'weight_dimensions' => 'setWeightDimensions', + 'vendor_code' => 'setVendorCode', + 'tags' => 'setTags', + 'shelf_life' => 'setShelfLife', + 'life_time' => 'setLifeTime', + 'guarantee_period' => 'setGuaranteePeriod', + 'customs_commodity_code' => 'setCustomsCommodityCode', + 'certificates' => 'setCertificates', + 'box_count' => 'setBoxCount', + 'condition' => 'setCondition', + 'type' => 'setType', + 'downloadable' => 'setDownloadable', + 'adult' => 'setAdult', + 'age' => 'setAge', + 'params' => 'setParams' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'name' => 'getName', + 'market_category_id' => 'getMarketCategoryId', + 'category' => 'getCategory', + 'pictures' => 'getPictures', + 'videos' => 'getVideos', + 'manuals' => 'getManuals', + 'vendor' => 'getVendor', + 'barcodes' => 'getBarcodes', + 'description' => 'getDescription', + 'manufacturer_countries' => 'getManufacturerCountries', + 'weight_dimensions' => 'getWeightDimensions', + 'vendor_code' => 'getVendorCode', + 'tags' => 'getTags', + 'shelf_life' => 'getShelfLife', + 'life_time' => 'getLifeTime', + 'guarantee_period' => 'getGuaranteePeriod', + 'customs_commodity_code' => 'getCustomsCommodityCode', + 'certificates' => 'getCertificates', + 'box_count' => 'getBoxCount', + 'condition' => 'getCondition', + 'type' => 'getType', + 'downloadable' => 'getDownloadable', + 'adult' => 'getAdult', + 'age' => 'getAge', + 'params' => 'getParams' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('market_category_id', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); + $this->setIfExists('pictures', $data ?? [], null); + $this->setIfExists('videos', $data ?? [], null); + $this->setIfExists('manuals', $data ?? [], null); + $this->setIfExists('vendor', $data ?? [], null); + $this->setIfExists('barcodes', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('manufacturer_countries', $data ?? [], null); + $this->setIfExists('weight_dimensions', $data ?? [], null); + $this->setIfExists('vendor_code', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); + $this->setIfExists('shelf_life', $data ?? [], null); + $this->setIfExists('life_time', $data ?? [], null); + $this->setIfExists('guarantee_period', $data ?? [], null); + $this->setIfExists('customs_commodity_code', $data ?? [], null); + $this->setIfExists('certificates', $data ?? [], null); + $this->setIfExists('box_count', $data ?? [], null); + $this->setIfExists('condition', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('downloadable', $data ?? [], null); + $this->setIfExists('adult', $data ?? [], null); + $this->setIfExists('age', $data ?? [], null); + $this->setIfExists('params', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 256)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['videos']) && (count($this->container['videos']) > 6)) { + $invalidProperties[] = "invalid value for 'videos', number of items must be less than or equal to 6."; + } + + if (!is_null($this->container['manuals']) && (count($this->container['manuals']) > 6)) { + $invalidProperties[] = "invalid value for 'manuals', number of items must be less than or equal to 6."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 6000)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 6000."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling BaseOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling BaseOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling BaseOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Составляйте название по схеме: тип + бренд или производитель + модель + особенности, если есть (например, цвет, размер или вес) и количество в упаковке. Не включайте в название условия продажи (например, «скидка», «бесплатная доставка» и т. д.), эмоциональные характеристики («хит», «супер» и т. д.). Не пишите слова большими буквами — кроме устоявшихся названий брендов и моделей. Оптимальная длина — 50–60 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/title.html) + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + if ((mb_strlen($name) > 256)) { + throw new \InvalidArgumentException('invalid length for $name when calling BaseOfferDTO., must be smaller than or equal to 256.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets market_category_id + * + * @return int|null + */ + public function getMarketCategoryId() + { + return $this->container['market_category_id']; + } + + /** + * Sets market_category_id + * + * @param int|null $market_category_id Идентификатор категории на Маркете, к которой вы относите свой товар. Если не указать `marketCategoryId`, то маркетная категория будет определена автоматически. При изменении информации о товаре передавайте тот же идентификатор категории. Если вы укажете другой, категория товара не поменяется. Изменить ее можно только в кабинете продавца на Маркете. Список категорий Маркета можно получить с помощью запроса [POST categories/tree](../../reference/categories/getCategoriesTree.md). + * + * @return self + */ + public function setMarketCategoryId($market_category_id) + { + if (is_null($market_category_id)) { + throw new \InvalidArgumentException('non-nullable market_category_id cannot be null'); + } + $this->container['market_category_id'] = $market_category_id; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category Категория товара в вашем магазине. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. Указывайте конкретные категории — например, набор ножей лучше отнести к категории **Столовые приборы**, а не просто **Посуда**. Выбирайте категории, которые описывают товар, а не абстрактный признак — например, **Духи**, а не **Подарки**. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. + * + * @return self + */ + public function setCategory($category) + { + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets pictures + * + * @return string[]|null + */ + public function getPictures() + { + return $this->container['pictures']; + } + + /** + * Sets pictures + * + * @param string[]|null $pictures Ссылки на изображения товара. Изображение по первой ссылке считается основным, остальные дополнительными. **Требования к ссылкам** * Ссылок может быть до 30. * Указывайте ссылку целиком, включая протокол http или https. * Максимальная длина — 512 символов. * Русские буквы в URL можно. * Можно использовать прямые ссылки на изображения и на Яндекс Диск. Ссылки на Яндекс Диске нужно копировать с помощью функции **Поделиться**. Относительные ссылки и ссылки на другие облачные хранилища — не работают. ✅ `https://example-shop.ru/images/sku12345.jpg` ✅ `https://yadi.sk/i/NaBoRsimVOLov` ❌ `/images/sku12345.jpg` ❌ `https://www.dropbox.com/s/818f/tovar.jpg` Ссылки на изображение должны быть постоянными. Нельзя использовать динамические ссылки, меняющиеся от выгрузки к выгрузке. Если нужно заменить изображение, выложите новое изображение по новой ссылке, а ссылку на старое удалите. Если просто заменить изображение по старой ссылке, оно не обновится. [Требования к изображениям](https://yandex.ru/support/marketplace/assortment/fields/images.html) + * + * @return self + */ + public function setPictures($pictures) + { + if (is_null($pictures)) { + array_push($this->openAPINullablesSetToNull, 'pictures'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('pictures', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['pictures'] = $pictures; + + return $this; + } + + /** + * Gets videos + * + * @return string[]|null + */ + public function getVideos() + { + return $this->container['videos']; + } + + /** + * Sets videos + * + * @param string[]|null $videos Ссылка (URL) на видео товара. Максимальное количество ссылок — 6. **Требования к ссылке** * Указывайте ссылку целиком, включая протокол http или https. * Максимальная длина — 512 символов. * Русские буквы в URL можно. * Можно использовать прямые ссылки на видео и на Яндекс Диск. Ссылки на Яндекс Диске нужно копировать с помощью функции **Поделиться**. Относительные ссылки и ссылки на другие облачные хранилища — не работают. ✅ `https://example-shop.ru/video/sku12345.avi` ✅ `https://yadi.sk/i/NaBoRsimVOLov` ❌ `/video/sku12345.avi` ❌ `https://www.dropbox.com/s/818f/super-tovar.avi` Ссылки на видео должны быть постоянными. Нельзя использовать динамические ссылки, меняющиеся от выгрузки к выгрузке. Если нужно заменить видео, выложите новое видео по новой ссылке, а ссылку на старое удалите. Если просто заменить видео по старой ссылке, оно не обновится. [Требования к видео](https://yandex.ru/support/marketplace/assortment/fields/video.html) + * + * @return self + */ + public function setVideos($videos) + { + if (is_null($videos)) { + array_push($this->openAPINullablesSetToNull, 'videos'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('videos', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($videos) && (count($videos) > 6)) { + throw new \InvalidArgumentException('invalid value for $videos when calling BaseOfferDTO., number of items must be less than or equal to 6.'); + } + $this->container['videos'] = $videos; + + return $this; + } + + /** + * Gets manuals + * + * @return \OpenAPI\Client\Model\OfferManualDTO[]|null + */ + public function getManuals() + { + return $this->container['manuals']; + } + + /** + * Sets manuals + * + * @param \OpenAPI\Client\Model\OfferManualDTO[]|null $manuals Список инструкций по использованию товара. Максимальное количество инструкций — 6. Если вы передадите пустое поле `manuals`, загруженные ранее инструкции удалятся. + * + * @return self + */ + public function setManuals($manuals) + { + if (is_null($manuals)) { + array_push($this->openAPINullablesSetToNull, 'manuals'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manuals', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($manuals) && (count($manuals) > 6)) { + throw new \InvalidArgumentException('invalid value for $manuals when calling BaseOfferDTO., number of items must be less than or equal to 6.'); + } + $this->container['manuals'] = $manuals; + + return $this; + } + + /** + * Gets vendor + * + * @return string|null + */ + public function getVendor() + { + return $this->container['vendor']; + } + + /** + * Sets vendor + * + * @param string|null $vendor Название бренда или производителя. Должно быть записано так, как его пишет сам бренд. + * + * @return self + */ + public function setVendor($vendor) + { + if (is_null($vendor)) { + throw new \InvalidArgumentException('non-nullable vendor cannot be null'); + } + $this->container['vendor'] = $vendor; + + return $this; + } + + /** + * Gets barcodes + * + * @return string[]|null + */ + public function getBarcodes() + { + return $this->container['barcodes']; + } + + /** + * Sets barcodes + * + * @param string[]|null $barcodes Указывайте в виде последовательности цифр. Подойдут коды EAN-13, EAN-8, UPC-A, UPC-E или Code 128. Для книг указывайте ISBN. Для товаров [определенных категорий и торговых марок](https://yastatic.net/s3/doc-binary/src/support/market/ru/yandex-market-list-for-gtin.xlsx) штрихкод должен быть действительным кодом GTIN. Обратите внимание: внутренние штрихкоды, начинающиеся на 2 или 02, и коды формата Code 128 не являются GTIN. [Что такое GTIN](*gtin) + * + * @return self + */ + public function setBarcodes($barcodes) + { + if (is_null($barcodes)) { + array_push($this->openAPINullablesSetToNull, 'barcodes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('barcodes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['barcodes'] = $barcodes; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Подробное описание товара: например, его преимущества и особенности. Не давайте в описании инструкций по установке и сборке. Не используйте слова «скидка», «распродажа», «дешевый», «подарок» (кроме подарочных категорий), «бесплатно», «акция», «специальная цена», «новинка», «new», «аналог», «заказ», «хит». Не указывайте никакой контактной информации и не давайте ссылок. Можно использовать теги: * \\, \\

, \\

и так далее — для заголовков; * \\
и \\

— для переноса строки; * \\

    — для нумерованного списка; * \\
      — для маркированного списка; * \\
    • — для создания элементов списка (должен находиться внутри \\
        или \\
          ); * \\
          — поддерживается, но не влияет на отображение текста. Оптимальная длина — 400–600 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/description.html) + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + if ((mb_strlen($description) > 6000)) { + throw new \InvalidArgumentException('invalid length for $description when calling BaseOfferDTO., must be smaller than or equal to 6000.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets manufacturer_countries + * + * @return string[]|null + */ + public function getManufacturerCountries() + { + return $this->container['manufacturer_countries']; + } + + /** + * Sets manufacturer_countries + * + * @param string[]|null $manufacturer_countries Страна, где был произведен товар. Записывайте названия стран так, как они записаны в [списке](https://yastatic.net/s3/doc-binary/src/support/market/ru/countries.xlsx). + * + * @return self + */ + public function setManufacturerCountries($manufacturer_countries) + { + if (is_null($manufacturer_countries)) { + array_push($this->openAPINullablesSetToNull, 'manufacturer_countries'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manufacturer_countries', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['manufacturer_countries'] = $manufacturer_countries; + + return $this; + } + + /** + * Gets weight_dimensions + * + * @return \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null + */ + public function getWeightDimensions() + { + return $this->container['weight_dimensions']; + } + + /** + * Sets weight_dimensions + * + * @param \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null $weight_dimensions weight_dimensions + * + * @return self + */ + public function setWeightDimensions($weight_dimensions) + { + if (is_null($weight_dimensions)) { + throw new \InvalidArgumentException('non-nullable weight_dimensions cannot be null'); + } + $this->container['weight_dimensions'] = $weight_dimensions; + + return $this; + } + + /** + * Gets vendor_code + * + * @return string|null + */ + public function getVendorCode() + { + return $this->container['vendor_code']; + } + + /** + * Sets vendor_code + * + * @param string|null $vendor_code Артикул товара от производителя. + * + * @return self + */ + public function setVendorCode($vendor_code) + { + if (is_null($vendor_code)) { + throw new \InvalidArgumentException('non-nullable vendor_code cannot be null'); + } + $this->container['vendor_code'] = $vendor_code; + + return $this; + } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Метки товара, используемые магазином. Покупателям теги не видны. По тегам можно группировать и фильтровать разные товары в каталоге — например, товары одной серии, коллекции или линейки. Максимальная длина тега 20 символов. У одного товара может быть максимум 10 тегов. Всего можно создать не больше 50 разных тегов. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + array_push($this->openAPINullablesSetToNull, 'tags'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tags', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tags'] = $tags; + + return $this; + } + + /** + * Gets shelf_life + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getShelfLife() + { + return $this->container['shelf_life']; + } + + /** + * Sets shelf_life + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $shelf_life shelf_life + * + * @return self + */ + public function setShelfLife($shelf_life) + { + if (is_null($shelf_life)) { + throw new \InvalidArgumentException('non-nullable shelf_life cannot be null'); + } + $this->container['shelf_life'] = $shelf_life; + + return $this; + } + + /** + * Gets life_time + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getLifeTime() + { + return $this->container['life_time']; + } + + /** + * Sets life_time + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $life_time life_time + * + * @return self + */ + public function setLifeTime($life_time) + { + if (is_null($life_time)) { + throw new \InvalidArgumentException('non-nullable life_time cannot be null'); + } + $this->container['life_time'] = $life_time; + + return $this; + } + + /** + * Gets guarantee_period + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getGuaranteePeriod() + { + return $this->container['guarantee_period']; + } + + /** + * Sets guarantee_period + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $guarantee_period guarantee_period + * + * @return self + */ + public function setGuaranteePeriod($guarantee_period) + { + if (is_null($guarantee_period)) { + throw new \InvalidArgumentException('non-nullable guarantee_period cannot be null'); + } + $this->container['guarantee_period'] = $guarantee_period; + + return $this; + } + + /** + * Gets customs_commodity_code + * + * @return string|null + */ + public function getCustomsCommodityCode() + { + return $this->container['customs_commodity_code']; + } + + /** + * Sets customs_commodity_code + * + * @param string|null $customs_commodity_code Код товара в единой Товарной номенклатуре внешнеэкономической деятельности (ТН ВЭД) — 10 или 14 цифр без пробелов. Обязательно укажите, если он есть. + * + * @return self + */ + public function setCustomsCommodityCode($customs_commodity_code) + { + if (is_null($customs_commodity_code)) { + throw new \InvalidArgumentException('non-nullable customs_commodity_code cannot be null'); + } + $this->container['customs_commodity_code'] = $customs_commodity_code; + + return $this; + } + + /** + * Gets certificates + * + * @return string[]|null + */ + public function getCertificates() + { + return $this->container['certificates']; + } + + /** + * Sets certificates + * + * @param string[]|null $certificates Номера документов на товар: сертификата, декларации соответствия и т. п. Передавать можно только номера документов, сканы которого загружены в кабинете продавца по [инструкции](https://yandex.ru/support/marketplace/assortment/restrictions/certificates.html). + * + * @return self + */ + public function setCertificates($certificates) + { + if (is_null($certificates)) { + array_push($this->openAPINullablesSetToNull, 'certificates'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('certificates', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['certificates'] = $certificates; + + return $this; + } + + /** + * Gets box_count + * + * @return int|null + */ + public function getBoxCount() + { + return $this->container['box_count']; + } + + /** + * Sets box_count + * + * @param int|null $box_count Количество грузовых мест. Параметр используется, если товар представляет собой несколько коробок, упаковок и так далее. Например, кондиционер занимает два места — внешний и внутренний блоки в двух коробках. Для товаров, занимающих одно место, не передавайте этот параметр. + * + * @return self + */ + public function setBoxCount($box_count) + { + if (is_null($box_count)) { + throw new \InvalidArgumentException('non-nullable box_count cannot be null'); + } + $this->container['box_count'] = $box_count; + + return $this; + } + + /** + * Gets condition + * + * @return \OpenAPI\Client\Model\OfferConditionDTO|null + */ + public function getCondition() + { + return $this->container['condition']; + } + + /** + * Sets condition + * + * @param \OpenAPI\Client\Model\OfferConditionDTO|null $condition condition + * + * @return self + */ + public function setCondition($condition) + { + if (is_null($condition)) { + throw new \InvalidArgumentException('non-nullable condition cannot be null'); + } + $this->container['condition'] = $condition; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OfferType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OfferType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets downloadable + * + * @return bool|null + */ + public function getDownloadable() + { + return $this->container['downloadable']; + } + + /** + * Sets downloadable + * + * @param bool|null $downloadable Признак цифрового товара. Укажите `true`, если товар доставляется по электронной почте. [Как работать с цифровыми товарами](../../step-by-step/digital.md) + * + * @return self + */ + public function setDownloadable($downloadable) + { + if (is_null($downloadable)) { + throw new \InvalidArgumentException('non-nullable downloadable cannot be null'); + } + $this->container['downloadable'] = $downloadable; + + return $this; + } + + /** + * Gets adult + * + * @return bool|null + */ + public function getAdult() + { + return $this->container['adult']; + } + + /** + * Sets adult + * + * @param bool|null $adult Параметр включает для товара пометку 18+. Устанавливайте ее только для товаров, которые относятся к удовлетворению сексуальных потребностей. + * + * @return self + */ + public function setAdult($adult) + { + if (is_null($adult)) { + throw new \InvalidArgumentException('non-nullable adult cannot be null'); + } + $this->container['adult'] = $adult; + + return $this; + } + + /** + * Gets age + * + * @return \OpenAPI\Client\Model\AgeDTO|null + */ + public function getAge() + { + return $this->container['age']; + } + + /** + * Sets age + * + * @param \OpenAPI\Client\Model\AgeDTO|null $age age + * + * @return self + */ + public function setAge($age) + { + if (is_null($age)) { + throw new \InvalidArgumentException('non-nullable age cannot be null'); + } + $this->container['age'] = $age; + + return $this; + } + + /** + * Gets params + * + * @return \OpenAPI\Client\Model\OfferParamDTO[]|null + * @deprecated + */ + public function getParams() + { + return $this->container['params']; + } + + /** + * Sets params + * + * @param \OpenAPI\Client\Model\OfferParamDTO[]|null $params {% note warning \"\" %} Этот параметр устарел. При передаче характеристик используйте `parameterValues`. {% endnote %} Характеристики, которые есть только у товаров конкретной категории — например, диаметр колес велосипеда или материал подошвы обуви. + * + * @return self + * @deprecated + */ + public function setParams($params) + { + if (is_null($params)) { + array_push($this->openAPINullablesSetToNull, 'params'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('params', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['params'] = $params; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BasePriceDTO.php b/erp24/lib/yandex_market_api/Model/BasePriceDTO.php new file mode 100644 index 00000000..4a234f45 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BasePriceDTO.php @@ -0,0 +1,459 @@ + + */ +class BasePriceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BasePriceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'float', + 'currency_id' => '\OpenAPI\Client\Model\CurrencyType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'currency_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'value' => false, + 'currency_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'currency_id' => 'currencyId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'currency_id' => 'setCurrencyId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'currency_id' => 'getCurrencyId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('currency_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if (($this->container['value'] <= 0)) { + $invalidProperties[] = "invalid value for 'value', must be bigger than 0."; + } + + if ($this->container['currency_id'] === null) { + $invalidProperties[] = "'currency_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return float + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param float $value Значение. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + + if (($value <= 0)) { + throw new \InvalidArgumentException('invalid value for $value when calling BasePriceDTO., must be bigger than 0.'); + } + + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets currency_id + * + * @return \OpenAPI\Client\Model\CurrencyType + */ + public function getCurrencyId() + { + return $this->container['currency_id']; + } + + /** + * Sets currency_id + * + * @param \OpenAPI\Client\Model\CurrencyType $currency_id currency_id + * + * @return self + */ + public function setCurrencyId($currency_id) + { + if (is_null($currency_id)) { + throw new \InvalidArgumentException('non-nullable currency_id cannot be null'); + } + $this->container['currency_id'] = $currency_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BaseShipmentDTO.php b/erp24/lib/yandex_market_api/Model/BaseShipmentDTO.php new file mode 100644 index 00000000..d98cd38c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BaseShipmentDTO.php @@ -0,0 +1,877 @@ + + */ +class BaseShipmentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BaseShipmentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'plan_interval_from' => '\DateTime', + 'plan_interval_to' => '\DateTime', + 'shipment_type' => '\OpenAPI\Client\Model\ShipmentType', + 'warehouse' => '\OpenAPI\Client\Model\PartnerShipmentWarehouseDTO', + 'warehouse_to' => '\OpenAPI\Client\Model\PartnerShipmentWarehouseDTO', + 'external_id' => 'string', + 'delivery_service' => '\OpenAPI\Client\Model\DeliveryServiceDTO', + 'pallets_count' => '\OpenAPI\Client\Model\PalletsCountDTO', + 'order_ids' => 'int[]', + 'draft_count' => 'int', + 'planned_count' => 'int', + 'fact_count' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'plan_interval_from' => 'date-time', + 'plan_interval_to' => 'date-time', + 'shipment_type' => null, + 'warehouse' => null, + 'warehouse_to' => null, + 'external_id' => null, + 'delivery_service' => null, + 'pallets_count' => null, + 'order_ids' => 'int64', + 'draft_count' => 'int32', + 'planned_count' => 'int32', + 'fact_count' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'plan_interval_from' => false, + 'plan_interval_to' => false, + 'shipment_type' => false, + 'warehouse' => false, + 'warehouse_to' => false, + 'external_id' => false, + 'delivery_service' => false, + 'pallets_count' => false, + 'order_ids' => false, + 'draft_count' => false, + 'planned_count' => false, + 'fact_count' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'plan_interval_from' => 'planIntervalFrom', + 'plan_interval_to' => 'planIntervalTo', + 'shipment_type' => 'shipmentType', + 'warehouse' => 'warehouse', + 'warehouse_to' => 'warehouseTo', + 'external_id' => 'externalId', + 'delivery_service' => 'deliveryService', + 'pallets_count' => 'palletsCount', + 'order_ids' => 'orderIds', + 'draft_count' => 'draftCount', + 'planned_count' => 'plannedCount', + 'fact_count' => 'factCount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'plan_interval_from' => 'setPlanIntervalFrom', + 'plan_interval_to' => 'setPlanIntervalTo', + 'shipment_type' => 'setShipmentType', + 'warehouse' => 'setWarehouse', + 'warehouse_to' => 'setWarehouseTo', + 'external_id' => 'setExternalId', + 'delivery_service' => 'setDeliveryService', + 'pallets_count' => 'setPalletsCount', + 'order_ids' => 'setOrderIds', + 'draft_count' => 'setDraftCount', + 'planned_count' => 'setPlannedCount', + 'fact_count' => 'setFactCount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'plan_interval_from' => 'getPlanIntervalFrom', + 'plan_interval_to' => 'getPlanIntervalTo', + 'shipment_type' => 'getShipmentType', + 'warehouse' => 'getWarehouse', + 'warehouse_to' => 'getWarehouseTo', + 'external_id' => 'getExternalId', + 'delivery_service' => 'getDeliveryService', + 'pallets_count' => 'getPalletsCount', + 'order_ids' => 'getOrderIds', + 'draft_count' => 'getDraftCount', + 'planned_count' => 'getPlannedCount', + 'fact_count' => 'getFactCount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('plan_interval_from', $data ?? [], null); + $this->setIfExists('plan_interval_to', $data ?? [], null); + $this->setIfExists('shipment_type', $data ?? [], null); + $this->setIfExists('warehouse', $data ?? [], null); + $this->setIfExists('warehouse_to', $data ?? [], null); + $this->setIfExists('external_id', $data ?? [], null); + $this->setIfExists('delivery_service', $data ?? [], null); + $this->setIfExists('pallets_count', $data ?? [], null); + $this->setIfExists('order_ids', $data ?? [], null); + $this->setIfExists('draft_count', $data ?? [], null); + $this->setIfExists('planned_count', $data ?? [], null); + $this->setIfExists('fact_count', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if (($this->container['id'] < 1)) { + $invalidProperties[] = "invalid value for 'id', must be bigger than or equal to 1."; + } + + if ($this->container['plan_interval_from'] === null) { + $invalidProperties[] = "'plan_interval_from' can't be null"; + } + if ($this->container['plan_interval_to'] === null) { + $invalidProperties[] = "'plan_interval_to' can't be null"; + } + if ($this->container['order_ids'] === null) { + $invalidProperties[] = "'order_ids' can't be null"; + } + if ($this->container['draft_count'] === null) { + $invalidProperties[] = "'draft_count' can't be null"; + } + if (($this->container['draft_count'] < 0)) { + $invalidProperties[] = "invalid value for 'draft_count', must be bigger than or equal to 0."; + } + + if ($this->container['planned_count'] === null) { + $invalidProperties[] = "'planned_count' can't be null"; + } + if (($this->container['planned_count'] < 0)) { + $invalidProperties[] = "invalid value for 'planned_count', must be bigger than or equal to 0."; + } + + if ($this->container['fact_count'] === null) { + $invalidProperties[] = "'fact_count' can't be null"; + } + if (($this->container['fact_count'] < 0)) { + $invalidProperties[] = "invalid value for 'fact_count', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор отгрузки. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + if (($id < 1)) { + throw new \InvalidArgumentException('invalid value for $id when calling BaseShipmentDTO., must be bigger than or equal to 1.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets plan_interval_from + * + * @return \DateTime + */ + public function getPlanIntervalFrom() + { + return $this->container['plan_interval_from']; + } + + /** + * Sets plan_interval_from + * + * @param \DateTime $plan_interval_from Начало планового интервала отгрузки. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setPlanIntervalFrom($plan_interval_from) + { + if (is_null($plan_interval_from)) { + throw new \InvalidArgumentException('non-nullable plan_interval_from cannot be null'); + } + $this->container['plan_interval_from'] = $plan_interval_from; + + return $this; + } + + /** + * Gets plan_interval_to + * + * @return \DateTime + */ + public function getPlanIntervalTo() + { + return $this->container['plan_interval_to']; + } + + /** + * Sets plan_interval_to + * + * @param \DateTime $plan_interval_to Конец планового интервала отгрузки. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setPlanIntervalTo($plan_interval_to) + { + if (is_null($plan_interval_to)) { + throw new \InvalidArgumentException('non-nullable plan_interval_to cannot be null'); + } + $this->container['plan_interval_to'] = $plan_interval_to; + + return $this; + } + + /** + * Gets shipment_type + * + * @return \OpenAPI\Client\Model\ShipmentType|null + */ + public function getShipmentType() + { + return $this->container['shipment_type']; + } + + /** + * Sets shipment_type + * + * @param \OpenAPI\Client\Model\ShipmentType|null $shipment_type shipment_type + * + * @return self + */ + public function setShipmentType($shipment_type) + { + if (is_null($shipment_type)) { + throw new \InvalidArgumentException('non-nullable shipment_type cannot be null'); + } + $this->container['shipment_type'] = $shipment_type; + + return $this; + } + + /** + * Gets warehouse + * + * @return \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null + */ + public function getWarehouse() + { + return $this->container['warehouse']; + } + + /** + * Sets warehouse + * + * @param \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null $warehouse warehouse + * + * @return self + */ + public function setWarehouse($warehouse) + { + if (is_null($warehouse)) { + throw new \InvalidArgumentException('non-nullable warehouse cannot be null'); + } + $this->container['warehouse'] = $warehouse; + + return $this; + } + + /** + * Gets warehouse_to + * + * @return \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null + */ + public function getWarehouseTo() + { + return $this->container['warehouse_to']; + } + + /** + * Sets warehouse_to + * + * @param \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null $warehouse_to warehouse_to + * + * @return self + */ + public function setWarehouseTo($warehouse_to) + { + if (is_null($warehouse_to)) { + throw new \InvalidArgumentException('non-nullable warehouse_to cannot be null'); + } + $this->container['warehouse_to'] = $warehouse_to; + + return $this; + } + + /** + * Gets external_id + * + * @return string|null + */ + public function getExternalId() + { + return $this->container['external_id']; + } + + /** + * Sets external_id + * + * @param string|null $external_id Идентификатор отгрузки в вашей системе. Если вы еще не передавали идентификатор, вернется идентификатор из параметра `id`. + * + * @return self + */ + public function setExternalId($external_id) + { + if (is_null($external_id)) { + throw new \InvalidArgumentException('non-nullable external_id cannot be null'); + } + $this->container['external_id'] = $external_id; + + return $this; + } + + /** + * Gets delivery_service + * + * @return \OpenAPI\Client\Model\DeliveryServiceDTO|null + */ + public function getDeliveryService() + { + return $this->container['delivery_service']; + } + + /** + * Sets delivery_service + * + * @param \OpenAPI\Client\Model\DeliveryServiceDTO|null $delivery_service delivery_service + * + * @return self + */ + public function setDeliveryService($delivery_service) + { + if (is_null($delivery_service)) { + throw new \InvalidArgumentException('non-nullable delivery_service cannot be null'); + } + $this->container['delivery_service'] = $delivery_service; + + return $this; + } + + /** + * Gets pallets_count + * + * @return \OpenAPI\Client\Model\PalletsCountDTO|null + */ + public function getPalletsCount() + { + return $this->container['pallets_count']; + } + + /** + * Sets pallets_count + * + * @param \OpenAPI\Client\Model\PalletsCountDTO|null $pallets_count pallets_count + * + * @return self + */ + public function setPalletsCount($pallets_count) + { + if (is_null($pallets_count)) { + throw new \InvalidArgumentException('non-nullable pallets_count cannot be null'); + } + $this->container['pallets_count'] = $pallets_count; + + return $this; + } + + /** + * Gets order_ids + * + * @return int[] + */ + public function getOrderIds() + { + return $this->container['order_ids']; + } + + /** + * Sets order_ids + * + * @param int[] $order_ids Идентификаторы заказов в отгрузке. + * + * @return self + */ + public function setOrderIds($order_ids) + { + if (is_null($order_ids)) { + throw new \InvalidArgumentException('non-nullable order_ids cannot be null'); + } + + + $this->container['order_ids'] = $order_ids; + + return $this; + } + + /** + * Gets draft_count + * + * @return int + */ + public function getDraftCount() + { + return $this->container['draft_count']; + } + + /** + * Sets draft_count + * + * @param int $draft_count Количество заказов, которое Маркет запланировал к отгрузке. + * + * @return self + */ + public function setDraftCount($draft_count) + { + if (is_null($draft_count)) { + throw new \InvalidArgumentException('non-nullable draft_count cannot be null'); + } + + if (($draft_count < 0)) { + throw new \InvalidArgumentException('invalid value for $draft_count when calling BaseShipmentDTO., must be bigger than or equal to 0.'); + } + + $this->container['draft_count'] = $draft_count; + + return $this; + } + + /** + * Gets planned_count + * + * @return int + */ + public function getPlannedCount() + { + return $this->container['planned_count']; + } + + /** + * Sets planned_count + * + * @param int $planned_count Количество заказов, которое Маркет подтвердил к отгрузке. + * + * @return self + */ + public function setPlannedCount($planned_count) + { + if (is_null($planned_count)) { + throw new \InvalidArgumentException('non-nullable planned_count cannot be null'); + } + + if (($planned_count < 0)) { + throw new \InvalidArgumentException('invalid value for $planned_count when calling BaseShipmentDTO., must be bigger than or equal to 0.'); + } + + $this->container['planned_count'] = $planned_count; + + return $this; + } + + /** + * Gets fact_count + * + * @return int + */ + public function getFactCount() + { + return $this->container['fact_count']; + } + + /** + * Sets fact_count + * + * @param int $fact_count Количество заказов, принятых в сортировочном центре или пункте приема. + * + * @return self + */ + public function setFactCount($fact_count) + { + if (is_null($fact_count)) { + throw new \InvalidArgumentException('non-nullable fact_count cannot be null'); + } + + if (($fact_count < 0)) { + throw new \InvalidArgumentException('invalid value for $fact_count when calling BaseShipmentDTO., must be bigger than or equal to 0.'); + } + + $this->container['fact_count'] = $fact_count; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BidRecommendationItemDTO.php b/erp24/lib/yandex_market_api/Model/BidRecommendationItemDTO.php new file mode 100644 index 00000000..caaf0bda --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BidRecommendationItemDTO.php @@ -0,0 +1,482 @@ + + */ +class BidRecommendationItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BidRecommendationItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bid' => 'int', + 'show_percent' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bid' => 'int32', + 'show_percent' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bid' => false, + 'show_percent' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bid' => 'bid', + 'show_percent' => 'showPercent' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bid' => 'setBid', + 'show_percent' => 'setShowPercent' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bid' => 'getBid', + 'show_percent' => 'getShowPercent' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('bid', $data ?? [], null); + $this->setIfExists('show_percent', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['bid'] === null) { + $invalidProperties[] = "'bid' can't be null"; + } + if (($this->container['bid'] > 9999)) { + $invalidProperties[] = "invalid value for 'bid', must be smaller than or equal to 9999."; + } + + if (($this->container['bid'] < 0)) { + $invalidProperties[] = "invalid value for 'bid', must be bigger than or equal to 0."; + } + + if ($this->container['show_percent'] === null) { + $invalidProperties[] = "'show_percent' can't be null"; + } + if (($this->container['show_percent'] > 100)) { + $invalidProperties[] = "invalid value for 'show_percent', must be smaller than or equal to 100."; + } + + if (($this->container['show_percent'] < 0)) { + $invalidProperties[] = "invalid value for 'show_percent', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets bid + * + * @return int + */ + public function getBid() + { + return $this->container['bid']; + } + + /** + * Sets bid + * + * @param int $bid Значение ставки. + * + * @return self + */ + public function setBid($bid) + { + if (is_null($bid)) { + throw new \InvalidArgumentException('non-nullable bid cannot be null'); + } + + if (($bid > 9999)) { + throw new \InvalidArgumentException('invalid value for $bid when calling BidRecommendationItemDTO., must be smaller than or equal to 9999.'); + } + if (($bid < 0)) { + throw new \InvalidArgumentException('invalid value for $bid when calling BidRecommendationItemDTO., must be bigger than or equal to 0.'); + } + + $this->container['bid'] = $bid; + + return $this; + } + + /** + * Gets show_percent + * + * @return int + */ + public function getShowPercent() + { + return $this->container['show_percent']; + } + + /** + * Sets show_percent + * + * @param int $show_percent Доля показов. + * + * @return self + */ + public function setShowPercent($show_percent) + { + if (is_null($show_percent)) { + throw new \InvalidArgumentException('non-nullable show_percent cannot be null'); + } + + if (($show_percent > 100)) { + throw new \InvalidArgumentException('invalid value for $show_percent when calling BidRecommendationItemDTO., must be smaller than or equal to 100.'); + } + if (($show_percent < 0)) { + throw new \InvalidArgumentException('invalid value for $show_percent when calling BidRecommendationItemDTO., must be bigger than or equal to 0.'); + } + + $this->container['show_percent'] = $show_percent; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BriefOrderItemDTO.php b/erp24/lib/yandex_market_api/Model/BriefOrderItemDTO.php new file mode 100644 index 00000000..27d28006 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BriefOrderItemDTO.php @@ -0,0 +1,643 @@ + + */ +class BriefOrderItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BriefOrderItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'vat' => '\OpenAPI\Client\Model\OrderVatType', + 'count' => 'int', + 'price' => 'float', + 'offer_name' => 'string', + 'offer_id' => 'string', + 'instances' => '\OpenAPI\Client\Model\OrderItemInstanceDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'vat' => null, + 'count' => 'int32', + 'price' => null, + 'offer_name' => null, + 'offer_id' => null, + 'instances' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'vat' => false, + 'count' => false, + 'price' => false, + 'offer_name' => false, + 'offer_id' => false, + 'instances' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'vat' => 'vat', + 'count' => 'count', + 'price' => 'price', + 'offer_name' => 'offerName', + 'offer_id' => 'offerId', + 'instances' => 'instances' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'vat' => 'setVat', + 'count' => 'setCount', + 'price' => 'setPrice', + 'offer_name' => 'setOfferName', + 'offer_id' => 'setOfferId', + 'instances' => 'setInstances' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'vat' => 'getVat', + 'count' => 'getCount', + 'price' => 'getPrice', + 'offer_name' => 'getOfferName', + 'offer_id' => 'getOfferId', + 'instances' => 'getInstances' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('vat', $data ?? [], null); + $this->setIfExists('count', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('offer_name', $data ?? [], null); + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('instances', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор товара в заказе. Позволяет идентифицировать товар в рамках данного заказа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets vat + * + * @return \OpenAPI\Client\Model\OrderVatType|null + */ + public function getVat() + { + return $this->container['vat']; + } + + /** + * Sets vat + * + * @param \OpenAPI\Client\Model\OrderVatType|null $vat vat + * + * @return self + */ + public function setVat($vat) + { + if (is_null($vat)) { + throw new \InvalidArgumentException('non-nullable vat cannot be null'); + } + $this->container['vat'] = $vat; + + return $this; + } + + /** + * Gets count + * + * @return int|null + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param int|null $count Количество единиц товара. + * + * @return self + */ + public function setCount($count) + { + if (is_null($count)) { + throw new \InvalidArgumentException('non-nullable count cannot be null'); + } + $this->container['count'] = $count; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price Цена на товар. Указана в той валюте, которая была задана в каталоге. Разделитель целой и дробной части — точка. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets offer_name + * + * @return string|null + */ + public function getOfferName() + { + return $this->container['offer_name']; + } + + /** + * Sets offer_name + * + * @param string|null $offer_name Название товара. + * + * @return self + */ + public function setOfferName($offer_name) + { + if (is_null($offer_name)) { + throw new \InvalidArgumentException('non-nullable offer_name cannot be null'); + } + $this->container['offer_name'] = $offer_name; + + return $this; + } + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling BriefOrderItemDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling BriefOrderItemDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling BriefOrderItemDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets instances + * + * @return \OpenAPI\Client\Model\OrderItemInstanceDTO[]|null + */ + public function getInstances() + { + return $this->container['instances']; + } + + /** + * Sets instances + * + * @param \OpenAPI\Client\Model\OrderItemInstanceDTO[]|null $instances Переданные вами коды маркировки. + * + * @return self + */ + public function setInstances($instances) + { + if (is_null($instances)) { + array_push($this->openAPINullablesSetToNull, 'instances'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('instances', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['instances'] = $instances; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BriefOrderItemInstanceDTO.php b/erp24/lib/yandex_market_api/Model/BriefOrderItemInstanceDTO.php new file mode 100644 index 00000000..d5e523b0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BriefOrderItemInstanceDTO.php @@ -0,0 +1,512 @@ + + */ +class BriefOrderItemInstanceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BriefOrderItemInstanceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'cis' => 'string', + 'uin' => 'string', + 'rnpt' => 'string', + 'gtd' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'cis' => null, + 'uin' => null, + 'rnpt' => null, + 'gtd' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'cis' => false, + 'uin' => false, + 'rnpt' => false, + 'gtd' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'cis' => 'cis', + 'uin' => 'uin', + 'rnpt' => 'rnpt', + 'gtd' => 'gtd' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'cis' => 'setCis', + 'uin' => 'setUin', + 'rnpt' => 'setRnpt', + 'gtd' => 'setGtd' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'cis' => 'getCis', + 'uin' => 'getUin', + 'rnpt' => 'getRnpt', + 'gtd' => 'getGtd' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('cis', $data ?? [], null); + $this->setIfExists('uin', $data ?? [], null); + $this->setIfExists('rnpt', $data ?? [], null); + $this->setIfExists('gtd', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets cis + * + * @return string|null + */ + public function getCis() + { + return $this->container['cis']; + } + + /** + * Sets cis + * + * @param string|null $cis Код идентификации единицы товара [в системе «Честный ЗНАК»](https://честныйзнак.рф/). {% note warning %} Не экранируйте косую черту в коде символа-разделителя `\\u001d`! ✅ `01030410947874432155Qbag!\\u001d93Zjqw` ❌ `01030410947874432155Qbag!\\\\u001d93Zjqw` Косые черты и кавычки в других местах экранируйте по правилам JSON: `\\\\` и `\\\"` {% endnote %} + * + * @return self + */ + public function setCis($cis) + { + if (is_null($cis)) { + throw new \InvalidArgumentException('non-nullable cis cannot be null'); + } + $this->container['cis'] = $cis; + + return $this; + } + + /** + * Gets uin + * + * @return string|null + */ + public function getUin() + { + return $this->container['uin']; + } + + /** + * Sets uin + * + * @param string|null $uin Уникальный идентификационный номер ювелирного изделия. Представляет собой число из 16 цифр. + * + * @return self + */ + public function setUin($uin) + { + if (is_null($uin)) { + throw new \InvalidArgumentException('non-nullable uin cannot be null'); + } + $this->container['uin'] = $uin; + + return $this; + } + + /** + * Gets rnpt + * + * @return string|null + */ + public function getRnpt() + { + return $this->container['rnpt']; + } + + /** + * Sets rnpt + * + * @param string|null $rnpt Регистрационный номер партии товара. Представляет собой строку из четырех чисел, разделенных косой чертой: ХХХХХХХХ/ХХХХХХ/ХХХХХХХ/ХХХ. Первая часть — код таможни, которая зарегистрировала декларацию на партию товара. Далее — дата, номер декларации и номер маркированного товара в декларации. + * + * @return self + */ + public function setRnpt($rnpt) + { + if (is_null($rnpt)) { + throw new \InvalidArgumentException('non-nullable rnpt cannot be null'); + } + $this->container['rnpt'] = $rnpt; + + return $this; + } + + /** + * Gets gtd + * + * @return string|null + */ + public function getGtd() + { + return $this->container['gtd']; + } + + /** + * Sets gtd + * + * @param string|null $gtd Грузовая таможенная декларация. Представляет собой строку из трех чисел, разделенных косой чертой: ХХХХХХХХ/ХХХХХХ/ХХХХХХХ. Первая часть — код таможни, которая зарегистрировала декларацию на ввезенные товары. Далее — дата и номер декларации. + * + * @return self + */ + public function setGtd($gtd) + { + if (is_null($gtd)) { + throw new \InvalidArgumentException('non-nullable gtd cannot be null'); + } + $this->container['gtd'] = $gtd; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BusinessDTO.php b/erp24/lib/yandex_market_api/Model/BusinessDTO.php new file mode 100644 index 00000000..6e93d2eb --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BusinessDTO.php @@ -0,0 +1,444 @@ + + */ +class BusinessDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BusinessDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор кабинета. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название бизнеса. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/BusinessSettingsDTO.php b/erp24/lib/yandex_market_api/Model/BusinessSettingsDTO.php new file mode 100644 index 00000000..c34ce38a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/BusinessSettingsDTO.php @@ -0,0 +1,444 @@ + + */ +class BusinessSettingsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'BusinessSettingsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'only_default_price' => 'bool', + 'currency' => '\OpenAPI\Client\Model\CurrencyType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'only_default_price' => null, + 'currency' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'only_default_price' => false, + 'currency' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'only_default_price' => 'onlyDefaultPrice', + 'currency' => 'currency' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'only_default_price' => 'setOnlyDefaultPrice', + 'currency' => 'setCurrency' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'only_default_price' => 'getOnlyDefaultPrice', + 'currency' => 'getCurrency' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('only_default_price', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets only_default_price + * + * @return bool|null + */ + public function getOnlyDefaultPrice() + { + return $this->container['only_default_price']; + } + + /** + * Sets only_default_price + * + * @param bool|null $only_default_price Можно ли установить только [базовую цену](*rule): * `false` — можно задать и базовую цену, и цены в конкретных магазинах. * `true` — можно задать только базовую цену. + * + * @return self + */ + public function setOnlyDefaultPrice($only_default_price) + { + if (is_null($only_default_price)) { + throw new \InvalidArgumentException('non-nullable only_default_price cannot be null'); + } + $this->container['only_default_price'] = $only_default_price; + + return $this; + } + + /** + * Gets currency + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CalculateTariffsOfferDTO.php b/erp24/lib/yandex_market_api/Model/CalculateTariffsOfferDTO.php new file mode 100644 index 00000000..b715e4d9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CalculateTariffsOfferDTO.php @@ -0,0 +1,695 @@ + + */ +class CalculateTariffsOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CalculateTariffsOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'category_id' => 'int', + 'price' => 'float', + 'length' => 'float', + 'width' => 'float', + 'height' => 'float', + 'weight' => 'float', + 'quantity' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'category_id' => 'int64', + 'price' => null, + 'length' => null, + 'width' => null, + 'height' => null, + 'weight' => null, + 'quantity' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'category_id' => false, + 'price' => false, + 'length' => false, + 'width' => false, + 'height' => false, + 'weight' => false, + 'quantity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'category_id' => 'categoryId', + 'price' => 'price', + 'length' => 'length', + 'width' => 'width', + 'height' => 'height', + 'weight' => 'weight', + 'quantity' => 'quantity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'category_id' => 'setCategoryId', + 'price' => 'setPrice', + 'length' => 'setLength', + 'width' => 'setWidth', + 'height' => 'setHeight', + 'weight' => 'setWeight', + 'quantity' => 'setQuantity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'category_id' => 'getCategoryId', + 'price' => 'getPrice', + 'length' => 'getLength', + 'width' => 'getWidth', + 'height' => 'getHeight', + 'weight' => 'getWeight', + 'quantity' => 'getQuantity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('category_id', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('length', $data ?? [], null); + $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('height', $data ?? [], null); + $this->setIfExists('weight', $data ?? [], null); + $this->setIfExists('quantity', $data ?? [], 1); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['category_id'] === null) { + $invalidProperties[] = "'category_id' can't be null"; + } + if (($this->container['category_id'] <= 0)) { + $invalidProperties[] = "invalid value for 'category_id', must be bigger than 0."; + } + + if ($this->container['price'] === null) { + $invalidProperties[] = "'price' can't be null"; + } + if (($this->container['price'] <= 0)) { + $invalidProperties[] = "invalid value for 'price', must be bigger than 0."; + } + + if ($this->container['length'] === null) { + $invalidProperties[] = "'length' can't be null"; + } + if (($this->container['length'] <= 0)) { + $invalidProperties[] = "invalid value for 'length', must be bigger than 0."; + } + + if ($this->container['width'] === null) { + $invalidProperties[] = "'width' can't be null"; + } + if (($this->container['width'] <= 0)) { + $invalidProperties[] = "invalid value for 'width', must be bigger than 0."; + } + + if ($this->container['height'] === null) { + $invalidProperties[] = "'height' can't be null"; + } + if (($this->container['height'] <= 0)) { + $invalidProperties[] = "invalid value for 'height', must be bigger than 0."; + } + + if ($this->container['weight'] === null) { + $invalidProperties[] = "'weight' can't be null"; + } + if (($this->container['weight'] <= 0)) { + $invalidProperties[] = "invalid value for 'weight', must be bigger than 0."; + } + + if (!is_null($this->container['quantity']) && ($this->container['quantity'] < 1)) { + $invalidProperties[] = "invalid value for 'quantity', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets category_id + * + * @return int + */ + public function getCategoryId() + { + return $this->container['category_id']; + } + + /** + * Sets category_id + * + * @param int $category_id Идентификатор категории товара на Маркете. Для расчета стоимости услуг необходимо указать идентификатор листовой категории товара — той, которая не имеет дочерних категорий. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). + * + * @return self + */ + public function setCategoryId($category_id) + { + if (is_null($category_id)) { + throw new \InvalidArgumentException('non-nullable category_id cannot be null'); + } + + if (($category_id <= 0)) { + throw new \InvalidArgumentException('invalid value for $category_id when calling CalculateTariffsOfferDTO., must be bigger than 0.'); + } + + $this->container['category_id'] = $category_id; + + return $this; + } + + /** + * Gets price + * + * @return float + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float $price Цена на товар в рублях. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + + if (($price <= 0)) { + throw new \InvalidArgumentException('invalid value for $price when calling CalculateTariffsOfferDTO., must be bigger than 0.'); + } + + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets length + * + * @return float + */ + public function getLength() + { + return $this->container['length']; + } + + /** + * Sets length + * + * @param float $length Длина товара в сантиметрах. + * + * @return self + */ + public function setLength($length) + { + if (is_null($length)) { + throw new \InvalidArgumentException('non-nullable length cannot be null'); + } + + if (($length <= 0)) { + throw new \InvalidArgumentException('invalid value for $length when calling CalculateTariffsOfferDTO., must be bigger than 0.'); + } + + $this->container['length'] = $length; + + return $this; + } + + /** + * Gets width + * + * @return float + */ + public function getWidth() + { + return $this->container['width']; + } + + /** + * Sets width + * + * @param float $width Ширина товара в сантиметрах. + * + * @return self + */ + public function setWidth($width) + { + if (is_null($width)) { + throw new \InvalidArgumentException('non-nullable width cannot be null'); + } + + if (($width <= 0)) { + throw new \InvalidArgumentException('invalid value for $width when calling CalculateTariffsOfferDTO., must be bigger than 0.'); + } + + $this->container['width'] = $width; + + return $this; + } + + /** + * Gets height + * + * @return float + */ + public function getHeight() + { + return $this->container['height']; + } + + /** + * Sets height + * + * @param float $height Высота товара в сантиметрах. + * + * @return self + */ + public function setHeight($height) + { + if (is_null($height)) { + throw new \InvalidArgumentException('non-nullable height cannot be null'); + } + + if (($height <= 0)) { + throw new \InvalidArgumentException('invalid value for $height when calling CalculateTariffsOfferDTO., must be bigger than 0.'); + } + + $this->container['height'] = $height; + + return $this; + } + + /** + * Gets weight + * + * @return float + */ + public function getWeight() + { + return $this->container['weight']; + } + + /** + * Sets weight + * + * @param float $weight Вес товара в килограммах. + * + * @return self + */ + public function setWeight($weight) + { + if (is_null($weight)) { + throw new \InvalidArgumentException('non-nullable weight cannot be null'); + } + + if (($weight <= 0)) { + throw new \InvalidArgumentException('invalid value for $weight when calling CalculateTariffsOfferDTO., must be bigger than 0.'); + } + + $this->container['weight'] = $weight; + + return $this; + } + + /** + * Gets quantity + * + * @return int|null + */ + public function getQuantity() + { + return $this->container['quantity']; + } + + /** + * Sets quantity + * + * @param int|null $quantity Квант продажи — количество единиц товара в одном товарном предложении. + * + * @return self + */ + public function setQuantity($quantity) + { + if (is_null($quantity)) { + throw new \InvalidArgumentException('non-nullable quantity cannot be null'); + } + + if (($quantity < 1)) { + throw new \InvalidArgumentException('invalid value for $quantity when calling CalculateTariffsOfferDTO., must be bigger than or equal to 1.'); + } + + $this->container['quantity'] = $quantity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CalculateTariffsOfferInfoDTO.php b/erp24/lib/yandex_market_api/Model/CalculateTariffsOfferInfoDTO.php new file mode 100644 index 00000000..0b4b2fb8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CalculateTariffsOfferInfoDTO.php @@ -0,0 +1,450 @@ + + */ +class CalculateTariffsOfferInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CalculateTariffsOfferInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer' => '\OpenAPI\Client\Model\CalculateTariffsOfferDTO', + 'tariffs' => '\OpenAPI\Client\Model\CalculatedTariffDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer' => null, + 'tariffs' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer' => false, + 'tariffs' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer' => 'offer', + 'tariffs' => 'tariffs' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer' => 'setOffer', + 'tariffs' => 'setTariffs' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer' => 'getOffer', + 'tariffs' => 'getTariffs' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer', $data ?? [], null); + $this->setIfExists('tariffs', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer'] === null) { + $invalidProperties[] = "'offer' can't be null"; + } + if ($this->container['tariffs'] === null) { + $invalidProperties[] = "'tariffs' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer + * + * @return \OpenAPI\Client\Model\CalculateTariffsOfferDTO + */ + public function getOffer() + { + return $this->container['offer']; + } + + /** + * Sets offer + * + * @param \OpenAPI\Client\Model\CalculateTariffsOfferDTO $offer offer + * + * @return self + */ + public function setOffer($offer) + { + if (is_null($offer)) { + throw new \InvalidArgumentException('non-nullable offer cannot be null'); + } + $this->container['offer'] = $offer; + + return $this; + } + + /** + * Gets tariffs + * + * @return \OpenAPI\Client\Model\CalculatedTariffDTO[] + */ + public function getTariffs() + { + return $this->container['tariffs']; + } + + /** + * Sets tariffs + * + * @param \OpenAPI\Client\Model\CalculatedTariffDTO[] $tariffs Список услуг и их стоимость. По некоторым услугам могут возвращаться несколько разных стоимостей. Например, в модели FBS стоимость услуги `SORTING` (обработка заказа) зависит от способа отгрузки и количества заказов в отгрузке. Подробнее о тарифах на услуги читайте [в Справке Маркета для продавцов](https://yandex.ru/support2/marketplace/ru/introduction/rates/models/). + * + * @return self + */ + public function setTariffs($tariffs) + { + if (is_null($tariffs)) { + throw new \InvalidArgumentException('non-nullable tariffs cannot be null'); + } + $this->container['tariffs'] = $tariffs; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CalculateTariffsParametersDTO.php b/erp24/lib/yandex_market_api/Model/CalculateTariffsParametersDTO.php new file mode 100644 index 00000000..b0ef7e44 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CalculateTariffsParametersDTO.php @@ -0,0 +1,487 @@ + + */ +class CalculateTariffsParametersDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CalculateTariffsParametersDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'selling_program' => '\OpenAPI\Client\Model\SellingProgramType', + 'frequency' => '\OpenAPI\Client\Model\PaymentFrequencyType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'selling_program' => null, + 'frequency' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'selling_program' => false, + 'frequency' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'selling_program' => 'sellingProgram', + 'frequency' => 'frequency' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'selling_program' => 'setSellingProgram', + 'frequency' => 'setFrequency' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'selling_program' => 'getSellingProgram', + 'frequency' => 'getFrequency' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('selling_program', $data ?? [], null); + $this->setIfExists('frequency', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['campaign_id']) && ($this->container['campaign_id'] < 1)) { + $invalidProperties[] = "invalid value for 'campaign_id', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int|null + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int|null $campaign_id Идентификатор кампании. У пользователя, который выполняет запрос, должен быть доступ к этой кампании. Используйте параметр `campaignId`, если уже завершили подключение магазина на Маркете. Иначе вернется пустой список. Обязательный параметр, если не указан параметр `sellingProgram`. Совместное использование параметров приведет к ошибке. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + + if (($campaign_id < 1)) { + throw new \InvalidArgumentException('invalid value for $campaign_id when calling CalculateTariffsParametersDTO., must be bigger than or equal to 1.'); + } + + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets selling_program + * + * @return \OpenAPI\Client\Model\SellingProgramType|null + */ + public function getSellingProgram() + { + return $this->container['selling_program']; + } + + /** + * Sets selling_program + * + * @param \OpenAPI\Client\Model\SellingProgramType|null $selling_program selling_program + * + * @return self + */ + public function setSellingProgram($selling_program) + { + if (is_null($selling_program)) { + throw new \InvalidArgumentException('non-nullable selling_program cannot be null'); + } + $this->container['selling_program'] = $selling_program; + + return $this; + } + + /** + * Gets frequency + * + * @return \OpenAPI\Client\Model\PaymentFrequencyType|null + */ + public function getFrequency() + { + return $this->container['frequency']; + } + + /** + * Sets frequency + * + * @param \OpenAPI\Client\Model\PaymentFrequencyType|null $frequency frequency + * + * @return self + */ + public function setFrequency($frequency) + { + if (is_null($frequency)) { + throw new \InvalidArgumentException('non-nullable frequency cannot be null'); + } + $this->container['frequency'] = $frequency; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CalculateTariffsRequest.php b/erp24/lib/yandex_market_api/Model/CalculateTariffsRequest.php new file mode 100644 index 00000000..43fca5f2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CalculateTariffsRequest.php @@ -0,0 +1,464 @@ + + */ +class CalculateTariffsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CalculateTariffsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'parameters' => '\OpenAPI\Client\Model\CalculateTariffsParametersDTO', + 'offers' => '\OpenAPI\Client\Model\CalculateTariffsOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'parameters' => null, + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'parameters' => false, + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'parameters' => 'parameters', + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'parameters' => 'setParameters', + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'parameters' => 'getParameters', + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('parameters', $data ?? [], null); + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['parameters'] === null) { + $invalidProperties[] = "'parameters' can't be null"; + } + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + if ((count($this->container['offers']) > 200)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be less than or equal to 200."; + } + + if ((count($this->container['offers']) < 1)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets parameters + * + * @return \OpenAPI\Client\Model\CalculateTariffsParametersDTO + */ + public function getParameters() + { + return $this->container['parameters']; + } + + /** + * Sets parameters + * + * @param \OpenAPI\Client\Model\CalculateTariffsParametersDTO $parameters parameters + * + * @return self + */ + public function setParameters($parameters) + { + if (is_null($parameters)) { + throw new \InvalidArgumentException('non-nullable parameters cannot be null'); + } + $this->container['parameters'] = $parameters; + + return $this; + } + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\CalculateTariffsOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\CalculateTariffsOfferDTO[] $offers Товары, для которых нужно рассчитать стоимость услуг. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + + if ((count($offers) > 200)) { + throw new \InvalidArgumentException('invalid value for $offers when calling CalculateTariffsRequest., number of items must be less than or equal to 200.'); + } + if ((count($offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $offers when calling CalculateTariffsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CalculateTariffsResponse.php b/erp24/lib/yandex_market_api/Model/CalculateTariffsResponse.php new file mode 100644 index 00000000..989e96df --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CalculateTariffsResponse.php @@ -0,0 +1,443 @@ + + */ +class CalculateTariffsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CalculateTariffsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\CalculateTariffsResponseDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\CalculateTariffsResponseDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\CalculateTariffsResponseDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CalculateTariffsResponseDTO.php b/erp24/lib/yandex_market_api/Model/CalculateTariffsResponseDTO.php new file mode 100644 index 00000000..da78206e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CalculateTariffsResponseDTO.php @@ -0,0 +1,413 @@ + + */ +class CalculateTariffsResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CalculateTariffsResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\CalculateTariffsOfferInfoDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\CalculateTariffsOfferInfoDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\CalculateTariffsOfferInfoDTO[] $offers Стоимость услуг. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CalculatedTariffDTO.php b/erp24/lib/yandex_market_api/Model/CalculatedTariffDTO.php new file mode 100644 index 00000000..522fc265 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CalculatedTariffDTO.php @@ -0,0 +1,484 @@ + + */ +class CalculatedTariffDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CalculatedTariffDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\CalculatedTariffType', + 'amount' => 'float', + 'parameters' => '\OpenAPI\Client\Model\TariffParameterDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'amount' => null, + 'parameters' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'amount' => false, + 'parameters' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'amount' => 'amount', + 'parameters' => 'parameters' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'amount' => 'setAmount', + 'parameters' => 'setParameters' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'amount' => 'getAmount', + 'parameters' => 'getParameters' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + $this->setIfExists('parameters', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['parameters'] === null) { + $invalidProperties[] = "'parameters' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\CalculatedTariffType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\CalculatedTariffType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets amount + * + * @return float|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param float|null $amount Стоимость услуги в рублях. + * + * @return self + */ + public function setAmount($amount) + { + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets parameters + * + * @return \OpenAPI\Client\Model\TariffParameterDTO[] + */ + public function getParameters() + { + return $this->container['parameters']; + } + + /** + * Sets parameters + * + * @param \OpenAPI\Client\Model\TariffParameterDTO[] $parameters Параметры расчета тарифа. + * + * @return self + */ + public function setParameters($parameters) + { + if (is_null($parameters)) { + throw new \InvalidArgumentException('non-nullable parameters cannot be null'); + } + $this->container['parameters'] = $parameters; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CalculatedTariffType.php b/erp24/lib/yandex_market_api/Model/CalculatedTariffType.php new file mode 100644 index 00000000..9f42f4e6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CalculatedTariffType.php @@ -0,0 +1,81 @@ + + */ +class CampaignDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CampaignDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'domain' => 'string', + 'id' => 'int', + 'client_id' => 'int', + 'business' => '\OpenAPI\Client\Model\BusinessDTO', + 'placement_type' => '\OpenAPI\Client\Model\PlacementType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'domain' => null, + 'id' => 'int64', + 'client_id' => 'int64', + 'business' => null, + 'placement_type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'domain' => false, + 'id' => false, + 'client_id' => false, + 'business' => false, + 'placement_type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'domain' => 'domain', + 'id' => 'id', + 'client_id' => 'clientId', + 'business' => 'business', + 'placement_type' => 'placementType' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'domain' => 'setDomain', + 'id' => 'setId', + 'client_id' => 'setClientId', + 'business' => 'setBusiness', + 'placement_type' => 'setPlacementType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'domain' => 'getDomain', + 'id' => 'getId', + 'client_id' => 'getClientId', + 'business' => 'getBusiness', + 'placement_type' => 'getPlacementType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('domain', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('client_id', $data ?? [], null); + $this->setIfExists('business', $data ?? [], null); + $this->setIfExists('placement_type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets domain + * + * @return string|null + */ + public function getDomain() + { + return $this->container['domain']; + } + + /** + * Sets domain + * + * @param string|null $domain URL магазина. + * + * @return self + */ + public function setDomain($domain) + { + if (is_null($domain)) { + throw new \InvalidArgumentException('non-nullable domain cannot be null'); + } + $this->container['domain'] = $domain; + + return $this; + } + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор кампании. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets client_id + * + * @return int|null + */ + public function getClientId() + { + return $this->container['client_id']; + } + + /** + * Sets client_id + * + * @param int|null $client_id Идентификатор плательщика в Яндекс Балансе. + * + * @return self + */ + public function setClientId($client_id) + { + if (is_null($client_id)) { + throw new \InvalidArgumentException('non-nullable client_id cannot be null'); + } + $this->container['client_id'] = $client_id; + + return $this; + } + + /** + * Gets business + * + * @return \OpenAPI\Client\Model\BusinessDTO|null + */ + public function getBusiness() + { + return $this->container['business']; + } + + /** + * Sets business + * + * @param \OpenAPI\Client\Model\BusinessDTO|null $business business + * + * @return self + */ + public function setBusiness($business) + { + if (is_null($business)) { + throw new \InvalidArgumentException('non-nullable business cannot be null'); + } + $this->container['business'] = $business; + + return $this; + } + + /** + * Gets placement_type + * + * @return \OpenAPI\Client\Model\PlacementType|null + */ + public function getPlacementType() + { + return $this->container['placement_type']; + } + + /** + * Sets placement_type + * + * @param \OpenAPI\Client\Model\PlacementType|null $placement_type placement_type + * + * @return self + */ + public function setPlacementType($placement_type) + { + if (is_null($placement_type)) { + throw new \InvalidArgumentException('non-nullable placement_type cannot be null'); + } + $this->container['placement_type'] = $placement_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CampaignQualityRatingDTO.php b/erp24/lib/yandex_market_api/Model/CampaignQualityRatingDTO.php new file mode 100644 index 00000000..560f5d12 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CampaignQualityRatingDTO.php @@ -0,0 +1,450 @@ + + */ +class CampaignQualityRatingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CampaignQualityRatingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'ratings' => '\OpenAPI\Client\Model\QualityRatingDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'ratings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'ratings' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'ratings' => 'ratings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'ratings' => 'setRatings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'ratings' => 'getRatings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('ratings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + if ($this->container['ratings'] === null) { + $invalidProperties[] = "'ratings' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор магазина. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets ratings + * + * @return \OpenAPI\Client\Model\QualityRatingDTO[] + */ + public function getRatings() + { + return $this->container['ratings']; + } + + /** + * Sets ratings + * + * @param \OpenAPI\Client\Model\QualityRatingDTO[] $ratings Список значений индекса качества. + * + * @return self + */ + public function setRatings($ratings) + { + if (is_null($ratings)) { + throw new \InvalidArgumentException('non-nullable ratings cannot be null'); + } + $this->container['ratings'] = $ratings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CampaignSettingsDTO.php b/erp24/lib/yandex_market_api/Model/CampaignSettingsDTO.php new file mode 100644 index 00000000..d635001b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CampaignSettingsDTO.php @@ -0,0 +1,580 @@ + + */ +class CampaignSettingsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CampaignSettingsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'country_region' => 'int', + 'shop_name' => 'string', + 'show_in_context' => 'bool', + 'show_in_premium' => 'bool', + 'use_open_stat' => 'bool', + 'local_region' => '\OpenAPI\Client\Model\CampaignSettingsLocalRegionDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'country_region' => 'int64', + 'shop_name' => null, + 'show_in_context' => null, + 'show_in_premium' => null, + 'use_open_stat' => null, + 'local_region' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'country_region' => false, + 'shop_name' => false, + 'show_in_context' => false, + 'show_in_premium' => false, + 'use_open_stat' => false, + 'local_region' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'country_region' => 'countryRegion', + 'shop_name' => 'shopName', + 'show_in_context' => 'showInContext', + 'show_in_premium' => 'showInPremium', + 'use_open_stat' => 'useOpenStat', + 'local_region' => 'localRegion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'country_region' => 'setCountryRegion', + 'shop_name' => 'setShopName', + 'show_in_context' => 'setShowInContext', + 'show_in_premium' => 'setShowInPremium', + 'use_open_stat' => 'setUseOpenStat', + 'local_region' => 'setLocalRegion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'country_region' => 'getCountryRegion', + 'shop_name' => 'getShopName', + 'show_in_context' => 'getShowInContext', + 'show_in_premium' => 'getShowInPremium', + 'use_open_stat' => 'getUseOpenStat', + 'local_region' => 'getLocalRegion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('country_region', $data ?? [], null); + $this->setIfExists('shop_name', $data ?? [], null); + $this->setIfExists('show_in_context', $data ?? [], null); + $this->setIfExists('show_in_premium', $data ?? [], null); + $this->setIfExists('use_open_stat', $data ?? [], null); + $this->setIfExists('local_region', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets country_region + * + * @return int|null + */ + public function getCountryRegion() + { + return $this->container['country_region']; + } + + /** + * Sets country_region + * + * @param int|null $country_region Идентификатор региона, в котором находится магазин. + * + * @return self + */ + public function setCountryRegion($country_region) + { + if (is_null($country_region)) { + throw new \InvalidArgumentException('non-nullable country_region cannot be null'); + } + $this->container['country_region'] = $country_region; + + return $this; + } + + /** + * Gets shop_name + * + * @return string|null + */ + public function getShopName() + { + return $this->container['shop_name']; + } + + /** + * Sets shop_name + * + * @param string|null $shop_name Наименование магазина на Яндекс Маркете. Если наименование отсутствует, значение параметра выводится — `null`. + * + * @return self + */ + public function setShopName($shop_name) + { + if (is_null($shop_name)) { + throw new \InvalidArgumentException('non-nullable shop_name cannot be null'); + } + $this->container['shop_name'] = $shop_name; + + return $this; + } + + /** + * Gets show_in_context + * + * @return bool|null + */ + public function getShowInContext() + { + return $this->container['show_in_context']; + } + + /** + * Sets show_in_context + * + * @param bool|null $show_in_context Признак размещения магазина на сайтах партнеров Яндекс Дистрибуции. Возможные значения: * `false` — магазин не размещен на сайтах партнеров Яндекс Дистрибуции. * `true` — магазин размещен на сайтах партнеров Яндекс Дистрибуции. + * + * @return self + */ + public function setShowInContext($show_in_context) + { + if (is_null($show_in_context)) { + throw new \InvalidArgumentException('non-nullable show_in_context cannot be null'); + } + $this->container['show_in_context'] = $show_in_context; + + return $this; + } + + /** + * Gets show_in_premium + * + * @return bool|null + */ + public function getShowInPremium() + { + return $this->container['show_in_premium']; + } + + /** + * Sets show_in_premium + * + * @param bool|null $show_in_premium Признак показа предложений магазина в рекламном блоке над результатами поиска (cпецразмещение). Возможные значения: * `false` — предложения не показываются в блоке cпецразмещения. * `true` — предложения показываются в блоке cпецразмещения. + * + * @return self + */ + public function setShowInPremium($show_in_premium) + { + if (is_null($show_in_premium)) { + throw new \InvalidArgumentException('non-nullable show_in_premium cannot be null'); + } + $this->container['show_in_premium'] = $show_in_premium; + + return $this; + } + + /** + * Gets use_open_stat + * + * @return bool|null + */ + public function getUseOpenStat() + { + return $this->container['use_open_stat']; + } + + /** + * Sets use_open_stat + * + * @param bool|null $use_open_stat Признак использования внешней интернет-статистики. Возможные значения: * `false` — внешняя интернет-статистика не используется. * `true` — внешняя интернет-статистика используется. + * + * @return self + */ + public function setUseOpenStat($use_open_stat) + { + if (is_null($use_open_stat)) { + throw new \InvalidArgumentException('non-nullable use_open_stat cannot be null'); + } + $this->container['use_open_stat'] = $use_open_stat; + + return $this; + } + + /** + * Gets local_region + * + * @return \OpenAPI\Client\Model\CampaignSettingsLocalRegionDTO|null + */ + public function getLocalRegion() + { + return $this->container['local_region']; + } + + /** + * Sets local_region + * + * @param \OpenAPI\Client\Model\CampaignSettingsLocalRegionDTO|null $local_region local_region + * + * @return self + */ + public function setLocalRegion($local_region) + { + if (is_null($local_region)) { + throw new \InvalidArgumentException('non-nullable local_region cannot be null'); + } + $this->container['local_region'] = $local_region; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CampaignSettingsDeliveryDTO.php b/erp24/lib/yandex_market_api/Model/CampaignSettingsDeliveryDTO.php new file mode 100644 index 00000000..3594c7cc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CampaignSettingsDeliveryDTO.php @@ -0,0 +1,410 @@ + + */ +class CampaignSettingsDeliveryDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CampaignSettingsDeliveryDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'schedule' => '\OpenAPI\Client\Model\CampaignSettingsScheduleDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'schedule' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'schedule' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'schedule' => 'schedule' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'schedule' => 'setSchedule' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'schedule' => 'getSchedule' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('schedule', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets schedule + * + * @return \OpenAPI\Client\Model\CampaignSettingsScheduleDTO|null + */ + public function getSchedule() + { + return $this->container['schedule']; + } + + /** + * Sets schedule + * + * @param \OpenAPI\Client\Model\CampaignSettingsScheduleDTO|null $schedule schedule + * + * @return self + */ + public function setSchedule($schedule) + { + if (is_null($schedule)) { + throw new \InvalidArgumentException('non-nullable schedule cannot be null'); + } + $this->container['schedule'] = $schedule; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CampaignSettingsLocalRegionDTO.php b/erp24/lib/yandex_market_api/Model/CampaignSettingsLocalRegionDTO.php new file mode 100644 index 00000000..b65e1a96 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CampaignSettingsLocalRegionDTO.php @@ -0,0 +1,546 @@ + + */ +class CampaignSettingsLocalRegionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CampaignSettingsLocalRegionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'type' => '\OpenAPI\Client\Model\RegionType', + 'delivery_options_source' => '\OpenAPI\Client\Model\CampaignSettingsScheduleSourceType', + 'delivery' => '\OpenAPI\Client\Model\CampaignSettingsDeliveryDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'type' => null, + 'delivery_options_source' => null, + 'delivery' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'type' => false, + 'delivery_options_source' => false, + 'delivery' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'type' => 'type', + 'delivery_options_source' => 'deliveryOptionsSource', + 'delivery' => 'delivery' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'type' => 'setType', + 'delivery_options_source' => 'setDeliveryOptionsSource', + 'delivery' => 'setDelivery' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'type' => 'getType', + 'delivery_options_source' => 'getDeliveryOptionsSource', + 'delivery' => 'getDelivery' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('delivery_options_source', $data ?? [], null); + $this->setIfExists('delivery', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор региона. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название региона. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\RegionType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\RegionType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets delivery_options_source + * + * @return \OpenAPI\Client\Model\CampaignSettingsScheduleSourceType|null + */ + public function getDeliveryOptionsSource() + { + return $this->container['delivery_options_source']; + } + + /** + * Sets delivery_options_source + * + * @param \OpenAPI\Client\Model\CampaignSettingsScheduleSourceType|null $delivery_options_source delivery_options_source + * + * @return self + */ + public function setDeliveryOptionsSource($delivery_options_source) + { + if (is_null($delivery_options_source)) { + throw new \InvalidArgumentException('non-nullable delivery_options_source cannot be null'); + } + $this->container['delivery_options_source'] = $delivery_options_source; + + return $this; + } + + /** + * Gets delivery + * + * @return \OpenAPI\Client\Model\CampaignSettingsDeliveryDTO|null + */ + public function getDelivery() + { + return $this->container['delivery']; + } + + /** + * Sets delivery + * + * @param \OpenAPI\Client\Model\CampaignSettingsDeliveryDTO|null $delivery delivery + * + * @return self + */ + public function setDelivery($delivery) + { + if (is_null($delivery)) { + throw new \InvalidArgumentException('non-nullable delivery cannot be null'); + } + $this->container['delivery'] = $delivery; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CampaignSettingsScheduleDTO.php b/erp24/lib/yandex_market_api/Model/CampaignSettingsScheduleDTO.php new file mode 100644 index 00000000..2c5959c0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CampaignSettingsScheduleDTO.php @@ -0,0 +1,592 @@ + + */ +class CampaignSettingsScheduleDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CampaignSettingsScheduleDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'available_on_holidays' => 'bool', + 'custom_holidays' => 'string[]', + 'custom_working_days' => 'string[]', + 'period' => '\OpenAPI\Client\Model\CampaignSettingsTimePeriodDTO', + 'total_holidays' => 'string[]', + 'weekly_holidays' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'available_on_holidays' => null, + 'custom_holidays' => 'date-dd-MM-yyyy', + 'custom_working_days' => 'date-dd-MM-yyyy', + 'period' => null, + 'total_holidays' => 'date-dd-MM-yyyy', + 'weekly_holidays' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'available_on_holidays' => false, + 'custom_holidays' => false, + 'custom_working_days' => false, + 'period' => false, + 'total_holidays' => false, + 'weekly_holidays' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'available_on_holidays' => 'availableOnHolidays', + 'custom_holidays' => 'customHolidays', + 'custom_working_days' => 'customWorkingDays', + 'period' => 'period', + 'total_holidays' => 'totalHolidays', + 'weekly_holidays' => 'weeklyHolidays' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'available_on_holidays' => 'setAvailableOnHolidays', + 'custom_holidays' => 'setCustomHolidays', + 'custom_working_days' => 'setCustomWorkingDays', + 'period' => 'setPeriod', + 'total_holidays' => 'setTotalHolidays', + 'weekly_holidays' => 'setWeeklyHolidays' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'available_on_holidays' => 'getAvailableOnHolidays', + 'custom_holidays' => 'getCustomHolidays', + 'custom_working_days' => 'getCustomWorkingDays', + 'period' => 'getPeriod', + 'total_holidays' => 'getTotalHolidays', + 'weekly_holidays' => 'getWeeklyHolidays' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('available_on_holidays', $data ?? [], null); + $this->setIfExists('custom_holidays', $data ?? [], null); + $this->setIfExists('custom_working_days', $data ?? [], null); + $this->setIfExists('period', $data ?? [], null); + $this->setIfExists('total_holidays', $data ?? [], null); + $this->setIfExists('weekly_holidays', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['custom_holidays'] === null) { + $invalidProperties[] = "'custom_holidays' can't be null"; + } + if ($this->container['custom_working_days'] === null) { + $invalidProperties[] = "'custom_working_days' can't be null"; + } + if ($this->container['total_holidays'] === null) { + $invalidProperties[] = "'total_holidays' can't be null"; + } + if ($this->container['weekly_holidays'] === null) { + $invalidProperties[] = "'weekly_holidays' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets available_on_holidays + * + * @return bool|null + */ + public function getAvailableOnHolidays() + { + return $this->container['available_on_holidays']; + } + + /** + * Sets available_on_holidays + * + * @param bool|null $available_on_holidays Признак работы службы доставки в государственные праздники. Возможные значения. * `false` — служба доставки не работает в праздничные дни. * `true` — служба доставки работает в праздничные дни. + * + * @return self + */ + public function setAvailableOnHolidays($available_on_holidays) + { + if (is_null($available_on_holidays)) { + throw new \InvalidArgumentException('non-nullable available_on_holidays cannot be null'); + } + $this->container['available_on_holidays'] = $available_on_holidays; + + return $this; + } + + /** + * Gets custom_holidays + * + * @return string[] + */ + public function getCustomHolidays() + { + return $this->container['custom_holidays']; + } + + /** + * Sets custom_holidays + * + * @param string[] $custom_holidays Список дней, в которые служба доставки не работает. Дни магазин указал в кабинете продавца на Маркете. + * + * @return self + */ + public function setCustomHolidays($custom_holidays) + { + if (is_null($custom_holidays)) { + throw new \InvalidArgumentException('non-nullable custom_holidays cannot be null'); + } + $this->container['custom_holidays'] = $custom_holidays; + + return $this; + } + + /** + * Gets custom_working_days + * + * @return string[] + */ + public function getCustomWorkingDays() + { + return $this->container['custom_working_days']; + } + + /** + * Sets custom_working_days + * + * @param string[] $custom_working_days Список выходных и праздничных дней, в которые служба доставки работает. Дни магазин указал в кабинете продавца на Маркете. + * + * @return self + */ + public function setCustomWorkingDays($custom_working_days) + { + if (is_null($custom_working_days)) { + throw new \InvalidArgumentException('non-nullable custom_working_days cannot be null'); + } + $this->container['custom_working_days'] = $custom_working_days; + + return $this; + } + + /** + * Gets period + * + * @return \OpenAPI\Client\Model\CampaignSettingsTimePeriodDTO|null + */ + public function getPeriod() + { + return $this->container['period']; + } + + /** + * Sets period + * + * @param \OpenAPI\Client\Model\CampaignSettingsTimePeriodDTO|null $period period + * + * @return self + */ + public function setPeriod($period) + { + if (is_null($period)) { + throw new \InvalidArgumentException('non-nullable period cannot be null'); + } + $this->container['period'] = $period; + + return $this; + } + + /** + * Gets total_holidays + * + * @return string[] + */ + public function getTotalHolidays() + { + return $this->container['total_holidays']; + } + + /** + * Sets total_holidays + * + * @param string[] $total_holidays Итоговый список нерабочих дней службы доставки. Список рассчитывается с учетом выходных, нерабочих дней и государственных праздников. Информацию по ним магазин указывает в кабинете продавца на Маркете. + * + * @return self + */ + public function setTotalHolidays($total_holidays) + { + if (is_null($total_holidays)) { + throw new \InvalidArgumentException('non-nullable total_holidays cannot be null'); + } + $this->container['total_holidays'] = $total_holidays; + + return $this; + } + + /** + * Gets weekly_holidays + * + * @return int[] + */ + public function getWeeklyHolidays() + { + return $this->container['weekly_holidays']; + } + + /** + * Sets weekly_holidays + * + * @param int[] $weekly_holidays Список выходных дней недели и государственных праздников. + * + * @return self + */ + public function setWeeklyHolidays($weekly_holidays) + { + if (is_null($weekly_holidays)) { + throw new \InvalidArgumentException('non-nullable weekly_holidays cannot be null'); + } + $this->container['weekly_holidays'] = $weekly_holidays; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CampaignSettingsScheduleSourceType.php b/erp24/lib/yandex_market_api/Model/CampaignSettingsScheduleSourceType.php new file mode 100644 index 00000000..297b3875 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CampaignSettingsScheduleSourceType.php @@ -0,0 +1,63 @@ + + */ +class CampaignSettingsTimePeriodDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CampaignSettingsTimePeriodDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'from_date' => 'string', + 'to_date' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'from_date' => 'date-dd-MM-yyyy', + 'to_date' => 'date-dd-MM-yyyy' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'from_date' => false, + 'to_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'from_date' => 'fromDate', + 'to_date' => 'toDate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'from_date' => 'setFromDate', + 'to_date' => 'setToDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'from_date' => 'getFromDate', + 'to_date' => 'getToDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('from_date', $data ?? [], null); + $this->setIfExists('to_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets from_date + * + * @return string|null + */ + public function getFromDate() + { + return $this->container['from_date']; + } + + /** + * Sets from_date + * + * @param string|null $from_date Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setFromDate($from_date) + { + if (is_null($from_date)) { + throw new \InvalidArgumentException('non-nullable from_date cannot be null'); + } + $this->container['from_date'] = $from_date; + + return $this; + } + + /** + * Gets to_date + * + * @return string|null + */ + public function getToDate() + { + return $this->container['to_date']; + } + + /** + * Sets to_date + * + * @param string|null $to_date Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setToDate($to_date) + { + if (is_null($to_date)) { + throw new \InvalidArgumentException('non-nullable to_date cannot be null'); + } + $this->container['to_date'] = $to_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CampaignsQualityRatingDTO.php b/erp24/lib/yandex_market_api/Model/CampaignsQualityRatingDTO.php new file mode 100644 index 00000000..ea612fb5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CampaignsQualityRatingDTO.php @@ -0,0 +1,413 @@ + + */ +class CampaignsQualityRatingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CampaignsQualityRatingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_ratings' => '\OpenAPI\Client\Model\CampaignQualityRatingDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_ratings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_ratings' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_ratings' => 'campaignRatings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_ratings' => 'setCampaignRatings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_ratings' => 'getCampaignRatings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_ratings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_ratings'] === null) { + $invalidProperties[] = "'campaign_ratings' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_ratings + * + * @return \OpenAPI\Client\Model\CampaignQualityRatingDTO[] + */ + public function getCampaignRatings() + { + return $this->container['campaign_ratings']; + } + + /** + * Sets campaign_ratings + * + * @param \OpenAPI\Client\Model\CampaignQualityRatingDTO[] $campaign_ratings Список магазинов c информацией об их индексе качества. + * + * @return self + */ + public function setCampaignRatings($campaign_ratings) + { + if (is_null($campaign_ratings)) { + throw new \InvalidArgumentException('non-nullable campaign_ratings cannot be null'); + } + $this->container['campaign_ratings'] = $campaign_ratings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CategoryContentParametersDTO.php b/erp24/lib/yandex_market_api/Model/CategoryContentParametersDTO.php new file mode 100644 index 00000000..4aa56d8e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CategoryContentParametersDTO.php @@ -0,0 +1,463 @@ + + */ +class CategoryContentParametersDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CategoryContentParametersDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'category_id' => 'int', + 'parameters' => '\OpenAPI\Client\Model\CategoryParameterDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'category_id' => 'int32', + 'parameters' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'category_id' => false, + 'parameters' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'category_id' => 'categoryId', + 'parameters' => 'parameters' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'category_id' => 'setCategoryId', + 'parameters' => 'setParameters' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'category_id' => 'getCategoryId', + 'parameters' => 'getParameters' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('category_id', $data ?? [], null); + $this->setIfExists('parameters', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['category_id'] === null) { + $invalidProperties[] = "'category_id' can't be null"; + } + if (($this->container['category_id'] < 1)) { + $invalidProperties[] = "invalid value for 'category_id', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets category_id + * + * @return int + */ + public function getCategoryId() + { + return $this->container['category_id']; + } + + /** + * Sets category_id + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). + * + * @return self + */ + public function setCategoryId($category_id) + { + if (is_null($category_id)) { + throw new \InvalidArgumentException('non-nullable category_id cannot be null'); + } + + if (($category_id < 1)) { + throw new \InvalidArgumentException('invalid value for $category_id when calling CategoryContentParametersDTO., must be bigger than or equal to 1.'); + } + + $this->container['category_id'] = $category_id; + + return $this; + } + + /** + * Gets parameters + * + * @return \OpenAPI\Client\Model\CategoryParameterDTO[]|null + */ + public function getParameters() + { + return $this->container['parameters']; + } + + /** + * Sets parameters + * + * @param \OpenAPI\Client\Model\CategoryParameterDTO[]|null $parameters Список характеристик. + * + * @return self + */ + public function setParameters($parameters) + { + if (is_null($parameters)) { + array_push($this->openAPINullablesSetToNull, 'parameters'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('parameters', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['parameters'] = $parameters; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CategoryDTO.php b/erp24/lib/yandex_market_api/Model/CategoryDTO.php new file mode 100644 index 00000000..2d404915 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CategoryDTO.php @@ -0,0 +1,491 @@ + + */ +class CategoryDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CategoryDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'children' => '\OpenAPI\Client\Model\CategoryDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'children' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'children' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'children' => 'children' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'children' => 'setChildren' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'children' => 'getChildren' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('children', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор категории. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название категории. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets children + * + * @return \OpenAPI\Client\Model\CategoryDTO[]|null + */ + public function getChildren() + { + return $this->container['children']; + } + + /** + * Sets children + * + * @param \OpenAPI\Client\Model\CategoryDTO[]|null $children Дочерние категории. + * + * @return self + */ + public function setChildren($children) + { + if (is_null($children)) { + array_push($this->openAPINullablesSetToNull, 'children'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('children', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['children'] = $children; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CategoryErrorDTO.php b/erp24/lib/yandex_market_api/Model/CategoryErrorDTO.php new file mode 100644 index 00000000..97111c0f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CategoryErrorDTO.php @@ -0,0 +1,444 @@ + + */ +class CategoryErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CategoryErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'category_id' => 'int', + 'type' => '\OpenAPI\Client\Model\CategoryErrorType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'category_id' => 'int64', + 'type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'category_id' => false, + 'type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'category_id' => 'categoryId', + 'type' => 'type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'category_id' => 'setCategoryId', + 'type' => 'setType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'category_id' => 'getCategoryId', + 'type' => 'getType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('category_id', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets category_id + * + * @return int|null + */ + public function getCategoryId() + { + return $this->container['category_id']; + } + + /** + * Sets category_id + * + * @param int|null $category_id Идентификатор категории. + * + * @return self + */ + public function setCategoryId($category_id) + { + if (is_null($category_id)) { + throw new \InvalidArgumentException('non-nullable category_id cannot be null'); + } + $this->container['category_id'] = $category_id; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\CategoryErrorType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\CategoryErrorType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CategoryErrorType.php b/erp24/lib/yandex_market_api/Model/CategoryErrorType.php new file mode 100644 index 00000000..d0c14e4f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CategoryErrorType.php @@ -0,0 +1,63 @@ + + */ +class CategoryParameterDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CategoryParameterDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'type' => '\OpenAPI\Client\Model\ParameterType', + 'unit' => '\OpenAPI\Client\Model\CategoryParameterUnitDTO', + 'description' => 'string', + 'recommendation_types' => '\OpenAPI\Client\Model\OfferCardRecommendationType[]', + 'required' => 'bool', + 'filtering' => 'bool', + 'distinctive' => 'bool', + 'multivalue' => 'bool', + 'allow_custom_values' => 'bool', + 'values' => '\OpenAPI\Client\Model\ParameterValueOptionDTO[]', + 'constraints' => '\OpenAPI\Client\Model\ParameterValueConstraintsDTO', + 'value_restrictions' => '\OpenAPI\Client\Model\ValueRestrictionDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'type' => null, + 'unit' => null, + 'description' => null, + 'recommendation_types' => null, + 'required' => null, + 'filtering' => null, + 'distinctive' => null, + 'multivalue' => null, + 'allow_custom_values' => null, + 'values' => null, + 'constraints' => null, + 'value_restrictions' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'type' => false, + 'unit' => false, + 'description' => false, + 'recommendation_types' => true, + 'required' => false, + 'filtering' => false, + 'distinctive' => false, + 'multivalue' => false, + 'allow_custom_values' => false, + 'values' => true, + 'constraints' => false, + 'value_restrictions' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'type' => 'type', + 'unit' => 'unit', + 'description' => 'description', + 'recommendation_types' => 'recommendationTypes', + 'required' => 'required', + 'filtering' => 'filtering', + 'distinctive' => 'distinctive', + 'multivalue' => 'multivalue', + 'allow_custom_values' => 'allowCustomValues', + 'values' => 'values', + 'constraints' => 'constraints', + 'value_restrictions' => 'valueRestrictions' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'type' => 'setType', + 'unit' => 'setUnit', + 'description' => 'setDescription', + 'recommendation_types' => 'setRecommendationTypes', + 'required' => 'setRequired', + 'filtering' => 'setFiltering', + 'distinctive' => 'setDistinctive', + 'multivalue' => 'setMultivalue', + 'allow_custom_values' => 'setAllowCustomValues', + 'values' => 'setValues', + 'constraints' => 'setConstraints', + 'value_restrictions' => 'setValueRestrictions' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'type' => 'getType', + 'unit' => 'getUnit', + 'description' => 'getDescription', + 'recommendation_types' => 'getRecommendationTypes', + 'required' => 'getRequired', + 'filtering' => 'getFiltering', + 'distinctive' => 'getDistinctive', + 'multivalue' => 'getMultivalue', + 'allow_custom_values' => 'getAllowCustomValues', + 'values' => 'getValues', + 'constraints' => 'getConstraints', + 'value_restrictions' => 'getValueRestrictions' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('unit', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('recommendation_types', $data ?? [], null); + $this->setIfExists('required', $data ?? [], null); + $this->setIfExists('filtering', $data ?? [], null); + $this->setIfExists('distinctive', $data ?? [], null); + $this->setIfExists('multivalue', $data ?? [], null); + $this->setIfExists('allow_custom_values', $data ?? [], null); + $this->setIfExists('values', $data ?? [], null); + $this->setIfExists('constraints', $data ?? [], null); + $this->setIfExists('value_restrictions', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if (($this->container['id'] < 1)) { + $invalidProperties[] = "invalid value for 'id', must be bigger than or equal to 1."; + } + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['required'] === null) { + $invalidProperties[] = "'required' can't be null"; + } + if ($this->container['filtering'] === null) { + $invalidProperties[] = "'filtering' can't be null"; + } + if ($this->container['distinctive'] === null) { + $invalidProperties[] = "'distinctive' can't be null"; + } + if ($this->container['multivalue'] === null) { + $invalidProperties[] = "'multivalue' can't be null"; + } + if ($this->container['allow_custom_values'] === null) { + $invalidProperties[] = "'allow_custom_values' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор характеристики. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + if (($id < 1)) { + throw new \InvalidArgumentException('invalid value for $id when calling CategoryParameterDTO., must be bigger than or equal to 1.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название характеристики. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\ParameterType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\ParameterType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets unit + * + * @return \OpenAPI\Client\Model\CategoryParameterUnitDTO|null + */ + public function getUnit() + { + return $this->container['unit']; + } + + /** + * Sets unit + * + * @param \OpenAPI\Client\Model\CategoryParameterUnitDTO|null $unit unit + * + * @return self + */ + public function setUnit($unit) + { + if (is_null($unit)) { + throw new \InvalidArgumentException('non-nullable unit cannot be null'); + } + $this->container['unit'] = $unit; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Описание характеристики. + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets recommendation_types + * + * @return \OpenAPI\Client\Model\OfferCardRecommendationType[]|null + */ + public function getRecommendationTypes() + { + return $this->container['recommendation_types']; + } + + /** + * Sets recommendation_types + * + * @param \OpenAPI\Client\Model\OfferCardRecommendationType[]|null $recommendation_types Перечень возможных рекомендаций по заполнению карточки, к которым относится данная характеристика. + * + * @return self + */ + public function setRecommendationTypes($recommendation_types) + { + if (is_null($recommendation_types)) { + array_push($this->openAPINullablesSetToNull, 'recommendation_types'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('recommendation_types', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['recommendation_types'] = $recommendation_types; + + return $this; + } + + /** + * Gets required + * + * @return bool + */ + public function getRequired() + { + return $this->container['required']; + } + + /** + * Sets required + * + * @param bool $required Обязательность характеристики. + * + * @return self + */ + public function setRequired($required) + { + if (is_null($required)) { + throw new \InvalidArgumentException('non-nullable required cannot be null'); + } + $this->container['required'] = $required; + + return $this; + } + + /** + * Gets filtering + * + * @return bool + */ + public function getFiltering() + { + return $this->container['filtering']; + } + + /** + * Sets filtering + * + * @param bool $filtering Используется ли характеристика в фильтре. + * + * @return self + */ + public function setFiltering($filtering) + { + if (is_null($filtering)) { + throw new \InvalidArgumentException('non-nullable filtering cannot be null'); + } + $this->container['filtering'] = $filtering; + + return $this; + } + + /** + * Gets distinctive + * + * @return bool + */ + public function getDistinctive() + { + return $this->container['distinctive']; + } + + /** + * Sets distinctive + * + * @param bool $distinctive Является ли характеристика особенностью варианта. + * + * @return self + */ + public function setDistinctive($distinctive) + { + if (is_null($distinctive)) { + throw new \InvalidArgumentException('non-nullable distinctive cannot be null'); + } + $this->container['distinctive'] = $distinctive; + + return $this; + } + + /** + * Gets multivalue + * + * @return bool + */ + public function getMultivalue() + { + return $this->container['multivalue']; + } + + /** + * Sets multivalue + * + * @param bool $multivalue Можно ли передать сразу несколько значений. + * + * @return self + */ + public function setMultivalue($multivalue) + { + if (is_null($multivalue)) { + throw new \InvalidArgumentException('non-nullable multivalue cannot be null'); + } + $this->container['multivalue'] = $multivalue; + + return $this; + } + + /** + * Gets allow_custom_values + * + * @return bool + */ + public function getAllowCustomValues() + { + return $this->container['allow_custom_values']; + } + + /** + * Sets allow_custom_values + * + * @param bool $allow_custom_values Можно ли передавать собственное значение, которого нет в списке вариантов Маркета. Только для характеристик типа `ENUM`. + * + * @return self + */ + public function setAllowCustomValues($allow_custom_values) + { + if (is_null($allow_custom_values)) { + throw new \InvalidArgumentException('non-nullable allow_custom_values cannot be null'); + } + $this->container['allow_custom_values'] = $allow_custom_values; + + return $this; + } + + /** + * Gets values + * + * @return \OpenAPI\Client\Model\ParameterValueOptionDTO[]|null + */ + public function getValues() + { + return $this->container['values']; + } + + /** + * Sets values + * + * @param \OpenAPI\Client\Model\ParameterValueOptionDTO[]|null $values Список допустимых значений параметра. Только для характеристик типа `ENUM`. + * + * @return self + */ + public function setValues($values) + { + if (is_null($values)) { + array_push($this->openAPINullablesSetToNull, 'values'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('values', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['values'] = $values; + + return $this; + } + + /** + * Gets constraints + * + * @return \OpenAPI\Client\Model\ParameterValueConstraintsDTO|null + */ + public function getConstraints() + { + return $this->container['constraints']; + } + + /** + * Sets constraints + * + * @param \OpenAPI\Client\Model\ParameterValueConstraintsDTO|null $constraints constraints + * + * @return self + */ + public function setConstraints($constraints) + { + if (is_null($constraints)) { + throw new \InvalidArgumentException('non-nullable constraints cannot be null'); + } + $this->container['constraints'] = $constraints; + + return $this; + } + + /** + * Gets value_restrictions + * + * @return \OpenAPI\Client\Model\ValueRestrictionDTO[]|null + */ + public function getValueRestrictions() + { + return $this->container['value_restrictions']; + } + + /** + * Sets value_restrictions + * + * @param \OpenAPI\Client\Model\ValueRestrictionDTO[]|null $value_restrictions Ограничения на значения, накладываемые другими характеристиками. Только для характеристик типа `ENUM`. + * + * @return self + */ + public function setValueRestrictions($value_restrictions) + { + if (is_null($value_restrictions)) { + array_push($this->openAPINullablesSetToNull, 'value_restrictions'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('value_restrictions', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['value_restrictions'] = $value_restrictions; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CategoryParameterUnitDTO.php b/erp24/lib/yandex_market_api/Model/CategoryParameterUnitDTO.php new file mode 100644 index 00000000..17d2c011 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CategoryParameterUnitDTO.php @@ -0,0 +1,450 @@ + + */ +class CategoryParameterUnitDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CategoryParameterUnitDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'default_unit_id' => 'int', + 'units' => '\OpenAPI\Client\Model\UnitDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'default_unit_id' => 'int64', + 'units' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'default_unit_id' => false, + 'units' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'default_unit_id' => 'defaultUnitId', + 'units' => 'units' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'default_unit_id' => 'setDefaultUnitId', + 'units' => 'setUnits' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'default_unit_id' => 'getDefaultUnitId', + 'units' => 'getUnits' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('default_unit_id', $data ?? [], null); + $this->setIfExists('units', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['default_unit_id'] === null) { + $invalidProperties[] = "'default_unit_id' can't be null"; + } + if ($this->container['units'] === null) { + $invalidProperties[] = "'units' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets default_unit_id + * + * @return int + */ + public function getDefaultUnitId() + { + return $this->container['default_unit_id']; + } + + /** + * Sets default_unit_id + * + * @param int $default_unit_id Единица измерения по умолчанию. + * + * @return self + */ + public function setDefaultUnitId($default_unit_id) + { + if (is_null($default_unit_id)) { + throw new \InvalidArgumentException('non-nullable default_unit_id cannot be null'); + } + $this->container['default_unit_id'] = $default_unit_id; + + return $this; + } + + /** + * Gets units + * + * @return \OpenAPI\Client\Model\UnitDTO[] + */ + public function getUnits() + { + return $this->container['units']; + } + + /** + * Sets units + * + * @param \OpenAPI\Client\Model\UnitDTO[] $units Допустимые единицы измерения. + * + * @return self + */ + public function setUnits($units) + { + if (is_null($units)) { + throw new \InvalidArgumentException('non-nullable units cannot be null'); + } + $this->container['units'] = $units; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ChangeOutletRequest.php b/erp24/lib/yandex_market_api/Model/ChangeOutletRequest.php new file mode 100644 index 00000000..c10ed750 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ChangeOutletRequest.php @@ -0,0 +1,780 @@ + + */ +class ChangeOutletRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChangeOutletRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'type' => '\OpenAPI\Client\Model\OutletType', + 'coords' => 'string', + 'is_main' => 'bool', + 'shop_outlet_code' => 'string', + 'visibility' => '\OpenAPI\Client\Model\OutletVisibilityType', + 'address' => '\OpenAPI\Client\Model\OutletAddressDTO', + 'phones' => 'string[]', + 'working_schedule' => '\OpenAPI\Client\Model\OutletWorkingScheduleDTO', + 'delivery_rules' => '\OpenAPI\Client\Model\OutletDeliveryRuleDTO[]', + 'storage_period' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'type' => null, + 'coords' => null, + 'is_main' => null, + 'shop_outlet_code' => null, + 'visibility' => null, + 'address' => null, + 'phones' => null, + 'working_schedule' => null, + 'delivery_rules' => null, + 'storage_period' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'type' => false, + 'coords' => false, + 'is_main' => false, + 'shop_outlet_code' => false, + 'visibility' => false, + 'address' => false, + 'phones' => false, + 'working_schedule' => false, + 'delivery_rules' => true, + 'storage_period' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'type' => 'type', + 'coords' => 'coords', + 'is_main' => 'isMain', + 'shop_outlet_code' => 'shopOutletCode', + 'visibility' => 'visibility', + 'address' => 'address', + 'phones' => 'phones', + 'working_schedule' => 'workingSchedule', + 'delivery_rules' => 'deliveryRules', + 'storage_period' => 'storagePeriod' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'type' => 'setType', + 'coords' => 'setCoords', + 'is_main' => 'setIsMain', + 'shop_outlet_code' => 'setShopOutletCode', + 'visibility' => 'setVisibility', + 'address' => 'setAddress', + 'phones' => 'setPhones', + 'working_schedule' => 'setWorkingSchedule', + 'delivery_rules' => 'setDeliveryRules', + 'storage_period' => 'setStoragePeriod' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'type' => 'getType', + 'coords' => 'getCoords', + 'is_main' => 'getIsMain', + 'shop_outlet_code' => 'getShopOutletCode', + 'visibility' => 'getVisibility', + 'address' => 'getAddress', + 'phones' => 'getPhones', + 'working_schedule' => 'getWorkingSchedule', + 'delivery_rules' => 'getDeliveryRules', + 'storage_period' => 'getStoragePeriod' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('coords', $data ?? [], null); + $this->setIfExists('is_main', $data ?? [], null); + $this->setIfExists('shop_outlet_code', $data ?? [], null); + $this->setIfExists('visibility', $data ?? [], null); + $this->setIfExists('address', $data ?? [], null); + $this->setIfExists('phones', $data ?? [], null); + $this->setIfExists('working_schedule', $data ?? [], null); + $this->setIfExists('delivery_rules', $data ?? [], null); + $this->setIfExists('storage_period', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['address'] === null) { + $invalidProperties[] = "'address' can't be null"; + } + if ($this->container['phones'] === null) { + $invalidProperties[] = "'phones' can't be null"; + } + if ((count($this->container['phones']) < 1)) { + $invalidProperties[] = "invalid value for 'phones', number of items must be greater than or equal to 1."; + } + + if ($this->container['working_schedule'] === null) { + $invalidProperties[] = "'working_schedule' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название точки продаж. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OutletType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OutletType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets coords + * + * @return string|null + */ + public function getCoords() + { + return $this->container['coords']; + } + + /** + * Sets coords + * + * @param string|null $coords Координаты точки продаж. Формат: долгота, широта. Разделители: запятая и / или пробел. Например, `20.4522144, 54.7104264`. Если параметр не передан, координаты будут определены по значениям параметров, вложенных в `address`. + * + * @return self + */ + public function setCoords($coords) + { + if (is_null($coords)) { + throw new \InvalidArgumentException('non-nullable coords cannot be null'); + } + $this->container['coords'] = $coords; + + return $this; + } + + /** + * Gets is_main + * + * @return bool|null + */ + public function getIsMain() + { + return $this->container['is_main']; + } + + /** + * Sets is_main + * + * @param bool|null $is_main Признак основной точки продаж. Возможные значения: * `false` — неосновная точка продаж. * `true` — основная точка продаж. + * + * @return self + */ + public function setIsMain($is_main) + { + if (is_null($is_main)) { + throw new \InvalidArgumentException('non-nullable is_main cannot be null'); + } + $this->container['is_main'] = $is_main; + + return $this; + } + + /** + * Gets shop_outlet_code + * + * @return string|null + */ + public function getShopOutletCode() + { + return $this->container['shop_outlet_code']; + } + + /** + * Sets shop_outlet_code + * + * @param string|null $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. + * + * @return self + */ + public function setShopOutletCode($shop_outlet_code) + { + if (is_null($shop_outlet_code)) { + throw new \InvalidArgumentException('non-nullable shop_outlet_code cannot be null'); + } + $this->container['shop_outlet_code'] = $shop_outlet_code; + + return $this; + } + + /** + * Gets visibility + * + * @return \OpenAPI\Client\Model\OutletVisibilityType|null + */ + public function getVisibility() + { + return $this->container['visibility']; + } + + /** + * Sets visibility + * + * @param \OpenAPI\Client\Model\OutletVisibilityType|null $visibility visibility + * + * @return self + */ + public function setVisibility($visibility) + { + if (is_null($visibility)) { + throw new \InvalidArgumentException('non-nullable visibility cannot be null'); + } + $this->container['visibility'] = $visibility; + + return $this; + } + + /** + * Gets address + * + * @return \OpenAPI\Client\Model\OutletAddressDTO + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \OpenAPI\Client\Model\OutletAddressDTO $address address + * + * @return self + */ + public function setAddress($address) + { + if (is_null($address)) { + throw new \InvalidArgumentException('non-nullable address cannot be null'); + } + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets phones + * + * @return string[] + */ + public function getPhones() + { + return $this->container['phones']; + } + + /** + * Sets phones + * + * @param string[] $phones Номера телефонов точки продаж. Передавайте в формате: `+7 (999) 999-99-99`. + * + * @return self + */ + public function setPhones($phones) + { + if (is_null($phones)) { + throw new \InvalidArgumentException('non-nullable phones cannot be null'); + } + + + if ((count($phones) < 1)) { + throw new \InvalidArgumentException('invalid length for $phones when calling ChangeOutletRequest., number of items must be greater than or equal to 1.'); + } + $this->container['phones'] = $phones; + + return $this; + } + + /** + * Gets working_schedule + * + * @return \OpenAPI\Client\Model\OutletWorkingScheduleDTO + */ + public function getWorkingSchedule() + { + return $this->container['working_schedule']; + } + + /** + * Sets working_schedule + * + * @param \OpenAPI\Client\Model\OutletWorkingScheduleDTO $working_schedule working_schedule + * + * @return self + */ + public function setWorkingSchedule($working_schedule) + { + if (is_null($working_schedule)) { + throw new \InvalidArgumentException('non-nullable working_schedule cannot be null'); + } + $this->container['working_schedule'] = $working_schedule; + + return $this; + } + + /** + * Gets delivery_rules + * + * @return \OpenAPI\Client\Model\OutletDeliveryRuleDTO[]|null + */ + public function getDeliveryRules() + { + return $this->container['delivery_rules']; + } + + /** + * Sets delivery_rules + * + * @param \OpenAPI\Client\Model\OutletDeliveryRuleDTO[]|null $delivery_rules Информация об условиях доставки для данной точки продаж. Обязательный параметр, если параметр `type=DEPOT` или `type=MIXED`. + * + * @return self + */ + public function setDeliveryRules($delivery_rules) + { + if (is_null($delivery_rules)) { + array_push($this->openAPINullablesSetToNull, 'delivery_rules'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('delivery_rules', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['delivery_rules'] = $delivery_rules; + + return $this; + } + + /** + * Gets storage_period + * + * @return int|null + */ + public function getStoragePeriod() + { + return $this->container['storage_period']; + } + + /** + * Sets storage_period + * + * @param int|null $storage_period Срок хранения заказа в собственном пункте выдачи заказов. Считается в днях. + * + * @return self + */ + public function setStoragePeriod($storage_period) + { + if (is_null($storage_period)) { + throw new \InvalidArgumentException('non-nullable storage_period cannot be null'); + } + $this->container['storage_period'] = $storage_period; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ChannelType.php b/erp24/lib/yandex_market_api/Model/ChannelType.php new file mode 100644 index 00000000..aada3ede --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ChannelType.php @@ -0,0 +1,382 @@ + + */ +class ChannelType implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChannelType'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ChatMessageDTO.php b/erp24/lib/yandex_market_api/Model/ChatMessageDTO.php new file mode 100644 index 00000000..d57da980 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ChatMessageDTO.php @@ -0,0 +1,562 @@ + + */ +class ChatMessageDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChatMessageDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'message_id' => 'int', + 'created_at' => '\DateTime', + 'sender' => '\OpenAPI\Client\Model\ChatMessageSenderType', + 'message' => 'string', + 'payload' => '\OpenAPI\Client\Model\ChatMessagePayloadDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'message_id' => 'int64', + 'created_at' => 'date-time', + 'sender' => null, + 'message' => null, + 'payload' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'message_id' => false, + 'created_at' => false, + 'sender' => false, + 'message' => false, + 'payload' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message_id' => 'messageId', + 'created_at' => 'createdAt', + 'sender' => 'sender', + 'message' => 'message', + 'payload' => 'payload' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message_id' => 'setMessageId', + 'created_at' => 'setCreatedAt', + 'sender' => 'setSender', + 'message' => 'setMessage', + 'payload' => 'setPayload' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message_id' => 'getMessageId', + 'created_at' => 'getCreatedAt', + 'sender' => 'getSender', + 'message' => 'getMessage', + 'payload' => 'getPayload' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('message_id', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('sender', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('payload', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['message_id'] === null) { + $invalidProperties[] = "'message_id' can't be null"; + } + if ($this->container['created_at'] === null) { + $invalidProperties[] = "'created_at' can't be null"; + } + if ($this->container['sender'] === null) { + $invalidProperties[] = "'sender' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message_id + * + * @return int + */ + public function getMessageId() + { + return $this->container['message_id']; + } + + /** + * Sets message_id + * + * @param int $message_id Идентификатор сообщения. + * + * @return self + */ + public function setMessageId($message_id) + { + if (is_null($message_id)) { + throw new \InvalidArgumentException('non-nullable message_id cannot be null'); + } + $this->container['message_id'] = $message_id; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime $created_at Дата и время создания сообщения. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setCreatedAt($created_at) + { + if (is_null($created_at)) { + throw new \InvalidArgumentException('non-nullable created_at cannot be null'); + } + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets sender + * + * @return \OpenAPI\Client\Model\ChatMessageSenderType + */ + public function getSender() + { + return $this->container['sender']; + } + + /** + * Sets sender + * + * @param \OpenAPI\Client\Model\ChatMessageSenderType $sender sender + * + * @return self + */ + public function setSender($sender) + { + if (is_null($sender)) { + throw new \InvalidArgumentException('non-nullable sender cannot be null'); + } + $this->container['sender'] = $sender; + + return $this; + } + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Текст сообщения. Необязательный параметр, если возвращается параметр `payload`. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets payload + * + * @return \OpenAPI\Client\Model\ChatMessagePayloadDTO[]|null + */ + public function getPayload() + { + return $this->container['payload']; + } + + /** + * Sets payload + * + * @param \OpenAPI\Client\Model\ChatMessagePayloadDTO[]|null $payload Информация о приложенных к сообщению файлах. Необязательный параметр, если возвращается параметр `message`. + * + * @return self + */ + public function setPayload($payload) + { + if (is_null($payload)) { + array_push($this->openAPINullablesSetToNull, 'payload'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('payload', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['payload'] = $payload; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ChatMessagePayloadDTO.php b/erp24/lib/yandex_market_api/Model/ChatMessagePayloadDTO.php new file mode 100644 index 00000000..d7f997ef --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ChatMessagePayloadDTO.php @@ -0,0 +1,496 @@ + + */ +class ChatMessagePayloadDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChatMessagePayloadDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'url' => 'string', + 'size' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'url' => null, + 'size' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'url' => false, + 'size' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'url' => 'url', + 'size' => 'size' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'url' => 'setUrl', + 'size' => 'setSize' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'url' => 'getUrl', + 'size' => 'getSize' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('size', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ((mb_strlen($this->container['name']) < 1)) { + $invalidProperties[] = "invalid value for 'name', the character length must be bigger than or equal to 1."; + } + + if ($this->container['url'] === null) { + $invalidProperties[] = "'url' can't be null"; + } + if ($this->container['size'] === null) { + $invalidProperties[] = "'size' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Имя файла. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + + if ((mb_strlen($name) < 1)) { + throw new \InvalidArgumentException('invalid length for $name when calling ChatMessagePayloadDTO., must be bigger than or equal to 1.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets url + * + * @return string + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string $url Ссылка для скачивания файла. + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets size + * + * @return int + */ + public function getSize() + { + return $this->container['size']; + } + + /** + * Sets size + * + * @param int $size Размер файла в байтах. + * + * @return self + */ + public function setSize($size) + { + if (is_null($size)) { + throw new \InvalidArgumentException('non-nullable size cannot be null'); + } + $this->container['size'] = $size; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ChatMessageSenderType.php b/erp24/lib/yandex_market_api/Model/ChatMessageSenderType.php new file mode 100644 index 00000000..5f2be1c4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ChatMessageSenderType.php @@ -0,0 +1,69 @@ + + */ +class ChatMessagesResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChatMessagesResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order_id' => 'int', + 'messages' => '\OpenAPI\Client\Model\ChatMessageDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order_id' => 'int64', + 'messages' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order_id' => false, + 'messages' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order_id' => 'orderId', + 'messages' => 'messages', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order_id' => 'setOrderId', + 'messages' => 'setMessages', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order_id' => 'getOrderId', + 'messages' => 'getMessages', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order_id', $data ?? [], null); + $this->setIfExists('messages', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['order_id'] === null) { + $invalidProperties[] = "'order_id' can't be null"; + } + if ($this->container['messages'] === null) { + $invalidProperties[] = "'messages' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order_id + * + * @return int + */ + public function getOrderId() + { + return $this->container['order_id']; + } + + /** + * Sets order_id + * + * @param int $order_id Идентификатор заказа. + * + * @return self + */ + public function setOrderId($order_id) + { + if (is_null($order_id)) { + throw new \InvalidArgumentException('non-nullable order_id cannot be null'); + } + $this->container['order_id'] = $order_id; + + return $this; + } + + /** + * Gets messages + * + * @return \OpenAPI\Client\Model\ChatMessageDTO[] + */ + public function getMessages() + { + return $this->container['messages']; + } + + /** + * Sets messages + * + * @param \OpenAPI\Client\Model\ChatMessageDTO[] $messages Информация о сообщениях. + * + * @return self + */ + public function setMessages($messages) + { + if (is_null($messages)) { + throw new \InvalidArgumentException('non-nullable messages cannot be null'); + } + $this->container['messages'] = $messages; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ChatStatusType.php b/erp24/lib/yandex_market_api/Model/ChatStatusType.php new file mode 100644 index 00000000..30c3c5ad --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ChatStatusType.php @@ -0,0 +1,75 @@ + + */ +class ConfirmPricesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ConfirmPricesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_ids'] === null) { + $invalidProperties[] = "'offer_ids' can't be null"; + } + if ((count($this->container['offer_ids']) > 200)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 200."; + } + + if ((count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[] + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[] $offer_ids Идентификаторы товаров, у которых подтверждается цена. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + throw new \InvalidArgumentException('non-nullable offer_ids cannot be null'); + } + + if ((count($offer_ids) > 200)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling ConfirmPricesRequest., number of items must be less than or equal to 200.'); + } + if ((count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling ConfirmPricesRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ConfirmShipmentRequest.php b/erp24/lib/yandex_market_api/Model/ConfirmShipmentRequest.php new file mode 100644 index 00000000..dd09ecee --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ConfirmShipmentRequest.php @@ -0,0 +1,410 @@ + + */ +class ConfirmShipmentRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ConfirmShipmentRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'external_shipment_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'external_shipment_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'external_shipment_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'external_shipment_id' => 'externalShipmentId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'external_shipment_id' => 'setExternalShipmentId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'external_shipment_id' => 'getExternalShipmentId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('external_shipment_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets external_shipment_id + * + * @return string|null + */ + public function getExternalShipmentId() + { + return $this->container['external_shipment_id']; + } + + /** + * Sets external_shipment_id + * + * @param string|null $external_shipment_id Идентификатор отгрузки в системе поставщика. + * + * @return self + */ + public function setExternalShipmentId($external_shipment_id) + { + if (is_null($external_shipment_id)) { + throw new \InvalidArgumentException('non-nullable external_shipment_id cannot be null'); + } + $this->container['external_shipment_id'] = $external_shipment_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CreateChatRequest.php b/erp24/lib/yandex_market_api/Model/CreateChatRequest.php new file mode 100644 index 00000000..02218442 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CreateChatRequest.php @@ -0,0 +1,413 @@ + + */ +class CreateChatRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CreateChatRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order_id' => 'orderId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order_id' => 'setOrderId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order_id' => 'getOrderId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['order_id'] === null) { + $invalidProperties[] = "'order_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order_id + * + * @return int + */ + public function getOrderId() + { + return $this->container['order_id']; + } + + /** + * Sets order_id + * + * @param int $order_id Идентификатор заказа на Маркете. + * + * @return self + */ + public function setOrderId($order_id) + { + if (is_null($order_id)) { + throw new \InvalidArgumentException('non-nullable order_id cannot be null'); + } + $this->container['order_id'] = $order_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CreateChatResponse.php b/erp24/lib/yandex_market_api/Model/CreateChatResponse.php new file mode 100644 index 00000000..451f7902 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CreateChatResponse.php @@ -0,0 +1,444 @@ + + */ +class CreateChatResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CreateChatResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\CreateChatResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\CreateChatResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\CreateChatResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CreateChatResultDTO.php b/erp24/lib/yandex_market_api/Model/CreateChatResultDTO.php new file mode 100644 index 00000000..0d1ed085 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CreateChatResultDTO.php @@ -0,0 +1,422 @@ + + */ +class CreateChatResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CreateChatResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'chat_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'chat_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'chat_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'chat_id' => 'chatId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'chat_id' => 'setChatId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'chat_id' => 'getChatId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('chat_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['chat_id'] === null) { + $invalidProperties[] = "'chat_id' can't be null"; + } + if (($this->container['chat_id'] < 1)) { + $invalidProperties[] = "invalid value for 'chat_id', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets chat_id + * + * @return int + */ + public function getChatId() + { + return $this->container['chat_id']; + } + + /** + * Sets chat_id + * + * @param int $chat_id Идентификатор чата. + * + * @return self + */ + public function setChatId($chat_id) + { + if (is_null($chat_id)) { + throw new \InvalidArgumentException('non-nullable chat_id cannot be null'); + } + + if (($chat_id < 1)) { + throw new \InvalidArgumentException('invalid value for $chat_id when calling CreateChatResultDTO., must be bigger than or equal to 1.'); + } + + $this->container['chat_id'] = $chat_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CreateOutletResponse.php b/erp24/lib/yandex_market_api/Model/CreateOutletResponse.php new file mode 100644 index 00000000..8a548b1d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CreateOutletResponse.php @@ -0,0 +1,444 @@ + + */ +class CreateOutletResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'CreateOutletResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OutletResponseDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OutletResponseDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OutletResponseDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/CurrencyType.php b/erp24/lib/yandex_market_api/Model/CurrencyType.php new file mode 100644 index 00000000..e56dc450 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/CurrencyType.php @@ -0,0 +1,426 @@ + + */ +class DeleteCampaignOffersDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteCampaignOffersDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'not_deleted_offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'not_deleted_offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'not_deleted_offer_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'not_deleted_offer_ids' => 'notDeletedOfferIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'not_deleted_offer_ids' => 'setNotDeletedOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'not_deleted_offer_ids' => 'getNotDeletedOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('not_deleted_offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets not_deleted_offer_ids + * + * @return string[]|null + */ + public function getNotDeletedOfferIds() + { + return $this->container['not_deleted_offer_ids']; + } + + /** + * Sets not_deleted_offer_ids + * + * @param string[]|null $not_deleted_offer_ids Список SKU. + * + * @return self + */ + public function setNotDeletedOfferIds($not_deleted_offer_ids) + { + if (is_null($not_deleted_offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'not_deleted_offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('not_deleted_offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['not_deleted_offer_ids'] = $not_deleted_offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteCampaignOffersRequest.php b/erp24/lib/yandex_market_api/Model/DeleteCampaignOffersRequest.php new file mode 100644 index 00000000..1b3809c5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteCampaignOffersRequest.php @@ -0,0 +1,428 @@ + + */ +class DeleteCampaignOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteCampaignOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_ids'] === null) { + $invalidProperties[] = "'offer_ids' can't be null"; + } + if ((count($this->container['offer_ids']) > 500)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 500."; + } + + if ((count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[] + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[] $offer_ids Идентификаторы товаров в каталоге. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + throw new \InvalidArgumentException('non-nullable offer_ids cannot be null'); + } + + if ((count($offer_ids) > 500)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling DeleteCampaignOffersRequest., number of items must be less than or equal to 500.'); + } + if ((count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling DeleteCampaignOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteCampaignOffersResponse.php b/erp24/lib/yandex_market_api/Model/DeleteCampaignOffersResponse.php new file mode 100644 index 00000000..7307be47 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteCampaignOffersResponse.php @@ -0,0 +1,444 @@ + + */ +class DeleteCampaignOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteCampaignOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\DeleteCampaignOffersDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\DeleteCampaignOffersDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\DeleteCampaignOffersDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteGoodsFeedbackCommentRequest.php b/erp24/lib/yandex_market_api/Model/DeleteGoodsFeedbackCommentRequest.php new file mode 100644 index 00000000..c46a7173 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteGoodsFeedbackCommentRequest.php @@ -0,0 +1,413 @@ + + */ +class DeleteGoodsFeedbackCommentRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteGoodsFeedbackCommentRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор комментария к отзыву. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteHiddenOffersRequest.php b/erp24/lib/yandex_market_api/Model/DeleteHiddenOffersRequest.php new file mode 100644 index 00000000..d0630536 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteHiddenOffersRequest.php @@ -0,0 +1,428 @@ + + */ +class DeleteHiddenOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteHiddenOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'hidden_offers' => '\OpenAPI\Client\Model\HiddenOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'hidden_offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'hidden_offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'hidden_offers' => 'hiddenOffers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'hidden_offers' => 'setHiddenOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'hidden_offers' => 'getHiddenOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('hidden_offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['hidden_offers'] === null) { + $invalidProperties[] = "'hidden_offers' can't be null"; + } + if ((count($this->container['hidden_offers']) > 500)) { + $invalidProperties[] = "invalid value for 'hidden_offers', number of items must be less than or equal to 500."; + } + + if ((count($this->container['hidden_offers']) < 1)) { + $invalidProperties[] = "invalid value for 'hidden_offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets hidden_offers + * + * @return \OpenAPI\Client\Model\HiddenOfferDTO[] + */ + public function getHiddenOffers() + { + return $this->container['hidden_offers']; + } + + /** + * Sets hidden_offers + * + * @param \OpenAPI\Client\Model\HiddenOfferDTO[] $hidden_offers Список скрытых товаров. + * + * @return self + */ + public function setHiddenOffers($hidden_offers) + { + if (is_null($hidden_offers)) { + throw new \InvalidArgumentException('non-nullable hidden_offers cannot be null'); + } + + if ((count($hidden_offers) > 500)) { + throw new \InvalidArgumentException('invalid value for $hidden_offers when calling DeleteHiddenOffersRequest., number of items must be less than or equal to 500.'); + } + if ((count($hidden_offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $hidden_offers when calling DeleteHiddenOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['hidden_offers'] = $hidden_offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteOffersDTO.php b/erp24/lib/yandex_market_api/Model/DeleteOffersDTO.php new file mode 100644 index 00000000..051bcbc3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteOffersDTO.php @@ -0,0 +1,417 @@ + + */ +class DeleteOffersDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteOffersDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'not_deleted_offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'not_deleted_offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'not_deleted_offer_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'not_deleted_offer_ids' => 'notDeletedOfferIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'not_deleted_offer_ids' => 'setNotDeletedOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'not_deleted_offer_ids' => 'getNotDeletedOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('not_deleted_offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets not_deleted_offer_ids + * + * @return string[]|null + */ + public function getNotDeletedOfferIds() + { + return $this->container['not_deleted_offer_ids']; + } + + /** + * Sets not_deleted_offer_ids + * + * @param string[]|null $not_deleted_offer_ids Список SKU товаров, которые не удалось удалить. + * + * @return self + */ + public function setNotDeletedOfferIds($not_deleted_offer_ids) + { + if (is_null($not_deleted_offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'not_deleted_offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('not_deleted_offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['not_deleted_offer_ids'] = $not_deleted_offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveDTO.php b/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveDTO.php new file mode 100644 index 00000000..246a9757 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveDTO.php @@ -0,0 +1,417 @@ + + */ +class DeleteOffersFromArchiveDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteOffersFromArchiveDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'not_unarchived_offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'not_unarchived_offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'not_unarchived_offer_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'not_unarchived_offer_ids' => 'notUnarchivedOfferIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'not_unarchived_offer_ids' => 'setNotUnarchivedOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'not_unarchived_offer_ids' => 'getNotUnarchivedOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('not_unarchived_offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets not_unarchived_offer_ids + * + * @return string[]|null + */ + public function getNotUnarchivedOfferIds() + { + return $this->container['not_unarchived_offer_ids']; + } + + /** + * Sets not_unarchived_offer_ids + * + * @param string[]|null $not_unarchived_offer_ids Список товаров, которые не удалось восстановить из архива. + * + * @return self + */ + public function setNotUnarchivedOfferIds($not_unarchived_offer_ids) + { + if (is_null($not_unarchived_offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'not_unarchived_offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('not_unarchived_offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['not_unarchived_offer_ids'] = $not_unarchived_offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveRequest.php b/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveRequest.php new file mode 100644 index 00000000..b81e6f5c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveRequest.php @@ -0,0 +1,428 @@ + + */ +class DeleteOffersFromArchiveRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteOffersFromArchiveRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_ids'] === null) { + $invalidProperties[] = "'offer_ids' can't be null"; + } + if ((count($this->container['offer_ids']) > 200)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 200."; + } + + if ((count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[] + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[] $offer_ids Список товаров, которые нужно восстановить из архива. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + throw new \InvalidArgumentException('non-nullable offer_ids cannot be null'); + } + + if ((count($offer_ids) > 200)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling DeleteOffersFromArchiveRequest., number of items must be less than or equal to 200.'); + } + if ((count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling DeleteOffersFromArchiveRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveResponse.php b/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveResponse.php new file mode 100644 index 00000000..17dfd7c3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteOffersFromArchiveResponse.php @@ -0,0 +1,444 @@ + + */ +class DeleteOffersFromArchiveResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteOffersFromArchiveResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\DeleteOffersFromArchiveDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\DeleteOffersFromArchiveDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\DeleteOffersFromArchiveDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteOffersRequest.php b/erp24/lib/yandex_market_api/Model/DeleteOffersRequest.php new file mode 100644 index 00000000..1e0215bf --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteOffersRequest.php @@ -0,0 +1,428 @@ + + */ +class DeleteOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_ids'] === null) { + $invalidProperties[] = "'offer_ids' can't be null"; + } + if ((count($this->container['offer_ids']) > 500)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 500."; + } + + if ((count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[] + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[] $offer_ids Список SKU товаров, которые нужно удалить. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + throw new \InvalidArgumentException('non-nullable offer_ids cannot be null'); + } + + if ((count($offer_ids) > 500)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling DeleteOffersRequest., number of items must be less than or equal to 500.'); + } + if ((count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling DeleteOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeleteOffersResponse.php b/erp24/lib/yandex_market_api/Model/DeleteOffersResponse.php new file mode 100644 index 00000000..4802b8ae --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeleteOffersResponse.php @@ -0,0 +1,444 @@ + + */ +class DeleteOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeleteOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\DeleteOffersDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\DeleteOffersDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\DeleteOffersDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeletePromoOffersRequest.php b/erp24/lib/yandex_market_api/Model/DeletePromoOffersRequest.php new file mode 100644 index 00000000..f2f51186 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeletePromoOffersRequest.php @@ -0,0 +1,503 @@ + + */ +class DeletePromoOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeletePromoOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'promo_id' => 'string', + 'delete_all_offers' => 'bool', + 'offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'promo_id' => null, + 'delete_all_offers' => null, + 'offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'promo_id' => false, + 'delete_all_offers' => false, + 'offer_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'promo_id' => 'promoId', + 'delete_all_offers' => 'deleteAllOffers', + 'offer_ids' => 'offerIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'promo_id' => 'setPromoId', + 'delete_all_offers' => 'setDeleteAllOffers', + 'offer_ids' => 'setOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'promo_id' => 'getPromoId', + 'delete_all_offers' => 'getDeleteAllOffers', + 'offer_ids' => 'getOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('promo_id', $data ?? [], null); + $this->setIfExists('delete_all_offers', $data ?? [], null); + $this->setIfExists('offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['promo_id'] === null) { + $invalidProperties[] = "'promo_id' can't be null"; + } + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) > 500)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 500."; + } + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets promo_id + * + * @return string + */ + public function getPromoId() + { + return $this->container['promo_id']; + } + + /** + * Sets promo_id + * + * @param string $promo_id Идентификатор акции. + * + * @return self + */ + public function setPromoId($promo_id) + { + if (is_null($promo_id)) { + throw new \InvalidArgumentException('non-nullable promo_id cannot be null'); + } + $this->container['promo_id'] = $promo_id; + + return $this; + } + + /** + * Gets delete_all_offers + * + * @return bool|null + */ + public function getDeleteAllOffers() + { + return $this->container['delete_all_offers']; + } + + /** + * Sets delete_all_offers + * + * @param bool|null $delete_all_offers Чтобы убрать все товары из акции и больше не участвовать в ней, передайте значение `true` и не передавайте параметр `offerIds`. + * + * @return self + */ + public function setDeleteAllOffers($delete_all_offers) + { + if (is_null($delete_all_offers)) { + throw new \InvalidArgumentException('non-nullable delete_all_offers cannot be null'); + } + $this->container['delete_all_offers'] = $delete_all_offers; + + return $this; + } + + /** + * Gets offer_ids + * + * @return string[]|null + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[]|null $offer_ids Товары, которые нужно убрать из акции. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($offer_ids) && (count($offer_ids) > 500)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling DeletePromoOffersRequest., number of items must be less than or equal to 500.'); + } + if (!is_null($offer_ids) && (count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling DeletePromoOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeletePromoOffersResponse.php b/erp24/lib/yandex_market_api/Model/DeletePromoOffersResponse.php new file mode 100644 index 00000000..533ebac1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeletePromoOffersResponse.php @@ -0,0 +1,444 @@ + + */ +class DeletePromoOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeletePromoOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\DeletePromoOffersResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\DeletePromoOffersResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\DeletePromoOffersResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeletePromoOffersResultDTO.php b/erp24/lib/yandex_market_api/Model/DeletePromoOffersResultDTO.php new file mode 100644 index 00000000..082f0290 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeletePromoOffersResultDTO.php @@ -0,0 +1,417 @@ + + */ +class DeletePromoOffersResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeletePromoOffersResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rejected_offers' => '\OpenAPI\Client\Model\RejectedPromoOfferDeleteDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rejected_offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rejected_offers' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rejected_offers' => 'rejectedOffers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rejected_offers' => 'setRejectedOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rejected_offers' => 'getRejectedOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('rejected_offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets rejected_offers + * + * @return \OpenAPI\Client\Model\RejectedPromoOfferDeleteDTO[]|null + */ + public function getRejectedOffers() + { + return $this->container['rejected_offers']; + } + + /** + * Sets rejected_offers + * + * @param \OpenAPI\Client\Model\RejectedPromoOfferDeleteDTO[]|null $rejected_offers Товары, при удалении которых появились ошибки. Возвращается, только если есть такие товары. + * + * @return self + */ + public function setRejectedOffers($rejected_offers) + { + if (is_null($rejected_offers)) { + array_push($this->openAPINullablesSetToNull, 'rejected_offers'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('rejected_offers', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['rejected_offers'] = $rejected_offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeliveryServiceDTO.php b/erp24/lib/yandex_market_api/Model/DeliveryServiceDTO.php new file mode 100644 index 00000000..4af5f626 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeliveryServiceDTO.php @@ -0,0 +1,444 @@ + + */ +class DeliveryServiceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeliveryServiceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор службы доставки. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Наименование службы доставки. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeliveryServiceInfoDTO.php b/erp24/lib/yandex_market_api/Model/DeliveryServiceInfoDTO.php new file mode 100644 index 00000000..86740936 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeliveryServiceInfoDTO.php @@ -0,0 +1,450 @@ + + */ +class DeliveryServiceInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeliveryServiceInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор службы доставки. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Наименование службы доставки. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DeliveryServicesDTO.php b/erp24/lib/yandex_market_api/Model/DeliveryServicesDTO.php new file mode 100644 index 00000000..c7398fde --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DeliveryServicesDTO.php @@ -0,0 +1,413 @@ + + */ +class DeliveryServicesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DeliveryServicesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'delivery_service' => '\OpenAPI\Client\Model\DeliveryServiceInfoDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'delivery_service' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'delivery_service' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'delivery_service' => 'deliveryService' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'delivery_service' => 'setDeliveryService' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'delivery_service' => 'getDeliveryService' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('delivery_service', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['delivery_service'] === null) { + $invalidProperties[] = "'delivery_service' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets delivery_service + * + * @return \OpenAPI\Client\Model\DeliveryServiceInfoDTO[] + */ + public function getDeliveryService() + { + return $this->container['delivery_service']; + } + + /** + * Sets delivery_service + * + * @param \OpenAPI\Client\Model\DeliveryServiceInfoDTO[] $delivery_service Информация о службе доставки. + * + * @return self + */ + public function setDeliveryService($delivery_service) + { + if (is_null($delivery_service)) { + throw new \InvalidArgumentException('non-nullable delivery_service cannot be null'); + } + $this->container['delivery_service'] = $delivery_service; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/DocumentDTO.php b/erp24/lib/yandex_market_api/Model/DocumentDTO.php new file mode 100644 index 00000000..e5c3151f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/DocumentDTO.php @@ -0,0 +1,478 @@ + + */ +class DocumentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'DocumentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\OrderDocumentStatusType', + 'number' => 'string', + 'date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'number' => null, + 'date' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'number' => false, + 'date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'number' => 'number', + 'date' => 'date' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'number' => 'setNumber', + 'date' => 'setDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'number' => 'getNumber', + 'date' => 'getDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('number', $data ?? [], null); + $this->setIfExists('date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OrderDocumentStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OrderDocumentStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets number + * + * @return string|null + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param string|null $number Номер документа. + * + * @return self + */ + public function setNumber($number) + { + if (is_null($number)) { + throw new \InvalidArgumentException('non-nullable number cannot be null'); + } + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets date + * + * @return \DateTime|null + */ + public function getDate() + { + return $this->container['date']; + } + + /** + * Sets date + * + * @param \DateTime|null $date Дата создания документа. + * + * @return self + */ + public function setDate($date) + { + if (is_null($date)) { + throw new \InvalidArgumentException('non-nullable date cannot be null'); + } + $this->container['date'] = $date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/EacVerificationResultDTO.php b/erp24/lib/yandex_market_api/Model/EacVerificationResultDTO.php new file mode 100644 index 00000000..3349b260 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/EacVerificationResultDTO.php @@ -0,0 +1,444 @@ + + */ +class EacVerificationResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'EacVerificationResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'verification_result' => '\OpenAPI\Client\Model\EacVerificationStatusType', + 'attempts_left' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'verification_result' => null, + 'attempts_left' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'verification_result' => false, + 'attempts_left' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'verification_result' => 'verificationResult', + 'attempts_left' => 'attemptsLeft' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'verification_result' => 'setVerificationResult', + 'attempts_left' => 'setAttemptsLeft' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'verification_result' => 'getVerificationResult', + 'attempts_left' => 'getAttemptsLeft' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('verification_result', $data ?? [], null); + $this->setIfExists('attempts_left', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets verification_result + * + * @return \OpenAPI\Client\Model\EacVerificationStatusType|null + */ + public function getVerificationResult() + { + return $this->container['verification_result']; + } + + /** + * Sets verification_result + * + * @param \OpenAPI\Client\Model\EacVerificationStatusType|null $verification_result verification_result + * + * @return self + */ + public function setVerificationResult($verification_result) + { + if (is_null($verification_result)) { + throw new \InvalidArgumentException('non-nullable verification_result cannot be null'); + } + $this->container['verification_result'] = $verification_result; + + return $this; + } + + /** + * Gets attempts_left + * + * @return int|null + */ + public function getAttemptsLeft() + { + return $this->container['attempts_left']; + } + + /** + * Sets attempts_left + * + * @param int|null $attempts_left Количество оставшихся попыток проверки кода. Возвращается, если магазин отправил некорректный код. Когда все попытки будут исчерпаны, код обновится. + * + * @return self + */ + public function setAttemptsLeft($attempts_left) + { + if (is_null($attempts_left)) { + throw new \InvalidArgumentException('non-nullable attempts_left cannot be null'); + } + $this->container['attempts_left'] = $attempts_left; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/EacVerificationStatusType.php b/erp24/lib/yandex_market_api/Model/EacVerificationStatusType.php new file mode 100644 index 00000000..9df7ebab --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/EacVerificationStatusType.php @@ -0,0 +1,66 @@ + + */ +class EmptyApiResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'EmptyApiResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/EnrichedMappingsOfferDTO.php b/erp24/lib/yandex_market_api/Model/EnrichedMappingsOfferDTO.php new file mode 100644 index 00000000..5afe69cc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/EnrichedMappingsOfferDTO.php @@ -0,0 +1,1745 @@ + + */ +class EnrichedMappingsOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'EnrichedMappingsOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'shop_sku' => 'string', + 'category' => 'string', + 'vendor' => 'string', + 'vendor_code' => 'string', + 'description' => 'string', + 'id' => 'string', + 'feed_id' => 'int', + 'barcodes' => 'string[]', + 'urls' => 'string[]', + 'pictures' => 'string[]', + 'manufacturer' => 'string', + 'manufacturer_countries' => 'string[]', + 'min_shipment' => 'int', + 'transport_unit_size' => 'int', + 'quantum_of_supply' => 'int', + 'delivery_duration_days' => 'int', + 'box_count' => 'int', + 'customs_commodity_codes' => 'string[]', + 'weight_dimensions' => '\OpenAPI\Client\Model\OfferWeightDimensionsDTO', + 'supply_schedule_days' => '\OpenAPI\Client\Model\DayOfWeekType[]', + 'shelf_life_days' => 'int', + 'life_time_days' => 'int', + 'guarantee_period_days' => 'int', + 'processing_state' => '\OpenAPI\Client\Model\OfferProcessingStateDTO', + 'availability' => '\OpenAPI\Client\Model\OfferAvailabilityStatusType', + 'shelf_life' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'life_time' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'guarantee_period' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'certificate' => 'string', + 'price' => 'float', + 'market_category_id' => 'int', + 'market_category_name' => 'string', + 'market_model_id' => 'int', + 'market_model_name' => 'string', + 'market_sku' => 'int', + 'market_sku_name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'shop_sku' => null, + 'category' => null, + 'vendor' => null, + 'vendor_code' => null, + 'description' => null, + 'id' => null, + 'feed_id' => 'int64', + 'barcodes' => null, + 'urls' => null, + 'pictures' => null, + 'manufacturer' => null, + 'manufacturer_countries' => null, + 'min_shipment' => 'int32', + 'transport_unit_size' => 'int32', + 'quantum_of_supply' => 'int32', + 'delivery_duration_days' => 'int32', + 'box_count' => 'int32', + 'customs_commodity_codes' => null, + 'weight_dimensions' => null, + 'supply_schedule_days' => null, + 'shelf_life_days' => 'int32', + 'life_time_days' => 'int32', + 'guarantee_period_days' => 'int32', + 'processing_state' => null, + 'availability' => null, + 'shelf_life' => null, + 'life_time' => null, + 'guarantee_period' => null, + 'certificate' => null, + 'price' => null, + 'market_category_id' => 'int64', + 'market_category_name' => null, + 'market_model_id' => 'int64', + 'market_model_name' => null, + 'market_sku' => 'int64', + 'market_sku_name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'shop_sku' => false, + 'category' => false, + 'vendor' => false, + 'vendor_code' => false, + 'description' => false, + 'id' => false, + 'feed_id' => false, + 'barcodes' => true, + 'urls' => true, + 'pictures' => true, + 'manufacturer' => false, + 'manufacturer_countries' => true, + 'min_shipment' => false, + 'transport_unit_size' => false, + 'quantum_of_supply' => false, + 'delivery_duration_days' => false, + 'box_count' => false, + 'customs_commodity_codes' => true, + 'weight_dimensions' => false, + 'supply_schedule_days' => true, + 'shelf_life_days' => false, + 'life_time_days' => false, + 'guarantee_period_days' => false, + 'processing_state' => false, + 'availability' => false, + 'shelf_life' => false, + 'life_time' => false, + 'guarantee_period' => false, + 'certificate' => false, + 'price' => false, + 'market_category_id' => false, + 'market_category_name' => false, + 'market_model_id' => false, + 'market_model_name' => false, + 'market_sku' => false, + 'market_sku_name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'shop_sku' => 'shopSku', + 'category' => 'category', + 'vendor' => 'vendor', + 'vendor_code' => 'vendorCode', + 'description' => 'description', + 'id' => 'id', + 'feed_id' => 'feedId', + 'barcodes' => 'barcodes', + 'urls' => 'urls', + 'pictures' => 'pictures', + 'manufacturer' => 'manufacturer', + 'manufacturer_countries' => 'manufacturerCountries', + 'min_shipment' => 'minShipment', + 'transport_unit_size' => 'transportUnitSize', + 'quantum_of_supply' => 'quantumOfSupply', + 'delivery_duration_days' => 'deliveryDurationDays', + 'box_count' => 'boxCount', + 'customs_commodity_codes' => 'customsCommodityCodes', + 'weight_dimensions' => 'weightDimensions', + 'supply_schedule_days' => 'supplyScheduleDays', + 'shelf_life_days' => 'shelfLifeDays', + 'life_time_days' => 'lifeTimeDays', + 'guarantee_period_days' => 'guaranteePeriodDays', + 'processing_state' => 'processingState', + 'availability' => 'availability', + 'shelf_life' => 'shelfLife', + 'life_time' => 'lifeTime', + 'guarantee_period' => 'guaranteePeriod', + 'certificate' => 'certificate', + 'price' => 'price', + 'market_category_id' => 'marketCategoryId', + 'market_category_name' => 'marketCategoryName', + 'market_model_id' => 'marketModelId', + 'market_model_name' => 'marketModelName', + 'market_sku' => 'marketSku', + 'market_sku_name' => 'marketSkuName' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'shop_sku' => 'setShopSku', + 'category' => 'setCategory', + 'vendor' => 'setVendor', + 'vendor_code' => 'setVendorCode', + 'description' => 'setDescription', + 'id' => 'setId', + 'feed_id' => 'setFeedId', + 'barcodes' => 'setBarcodes', + 'urls' => 'setUrls', + 'pictures' => 'setPictures', + 'manufacturer' => 'setManufacturer', + 'manufacturer_countries' => 'setManufacturerCountries', + 'min_shipment' => 'setMinShipment', + 'transport_unit_size' => 'setTransportUnitSize', + 'quantum_of_supply' => 'setQuantumOfSupply', + 'delivery_duration_days' => 'setDeliveryDurationDays', + 'box_count' => 'setBoxCount', + 'customs_commodity_codes' => 'setCustomsCommodityCodes', + 'weight_dimensions' => 'setWeightDimensions', + 'supply_schedule_days' => 'setSupplyScheduleDays', + 'shelf_life_days' => 'setShelfLifeDays', + 'life_time_days' => 'setLifeTimeDays', + 'guarantee_period_days' => 'setGuaranteePeriodDays', + 'processing_state' => 'setProcessingState', + 'availability' => 'setAvailability', + 'shelf_life' => 'setShelfLife', + 'life_time' => 'setLifeTime', + 'guarantee_period' => 'setGuaranteePeriod', + 'certificate' => 'setCertificate', + 'price' => 'setPrice', + 'market_category_id' => 'setMarketCategoryId', + 'market_category_name' => 'setMarketCategoryName', + 'market_model_id' => 'setMarketModelId', + 'market_model_name' => 'setMarketModelName', + 'market_sku' => 'setMarketSku', + 'market_sku_name' => 'setMarketSkuName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'shop_sku' => 'getShopSku', + 'category' => 'getCategory', + 'vendor' => 'getVendor', + 'vendor_code' => 'getVendorCode', + 'description' => 'getDescription', + 'id' => 'getId', + 'feed_id' => 'getFeedId', + 'barcodes' => 'getBarcodes', + 'urls' => 'getUrls', + 'pictures' => 'getPictures', + 'manufacturer' => 'getManufacturer', + 'manufacturer_countries' => 'getManufacturerCountries', + 'min_shipment' => 'getMinShipment', + 'transport_unit_size' => 'getTransportUnitSize', + 'quantum_of_supply' => 'getQuantumOfSupply', + 'delivery_duration_days' => 'getDeliveryDurationDays', + 'box_count' => 'getBoxCount', + 'customs_commodity_codes' => 'getCustomsCommodityCodes', + 'weight_dimensions' => 'getWeightDimensions', + 'supply_schedule_days' => 'getSupplyScheduleDays', + 'shelf_life_days' => 'getShelfLifeDays', + 'life_time_days' => 'getLifeTimeDays', + 'guarantee_period_days' => 'getGuaranteePeriodDays', + 'processing_state' => 'getProcessingState', + 'availability' => 'getAvailability', + 'shelf_life' => 'getShelfLife', + 'life_time' => 'getLifeTime', + 'guarantee_period' => 'getGuaranteePeriod', + 'certificate' => 'getCertificate', + 'price' => 'getPrice', + 'market_category_id' => 'getMarketCategoryId', + 'market_category_name' => 'getMarketCategoryName', + 'market_model_id' => 'getMarketModelId', + 'market_model_name' => 'getMarketModelName', + 'market_sku' => 'getMarketSku', + 'market_sku_name' => 'getMarketSkuName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('shop_sku', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); + $this->setIfExists('vendor', $data ?? [], null); + $this->setIfExists('vendor_code', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('feed_id', $data ?? [], null); + $this->setIfExists('barcodes', $data ?? [], null); + $this->setIfExists('urls', $data ?? [], null); + $this->setIfExists('pictures', $data ?? [], null); + $this->setIfExists('manufacturer', $data ?? [], null); + $this->setIfExists('manufacturer_countries', $data ?? [], null); + $this->setIfExists('min_shipment', $data ?? [], null); + $this->setIfExists('transport_unit_size', $data ?? [], null); + $this->setIfExists('quantum_of_supply', $data ?? [], null); + $this->setIfExists('delivery_duration_days', $data ?? [], null); + $this->setIfExists('box_count', $data ?? [], null); + $this->setIfExists('customs_commodity_codes', $data ?? [], null); + $this->setIfExists('weight_dimensions', $data ?? [], null); + $this->setIfExists('supply_schedule_days', $data ?? [], null); + $this->setIfExists('shelf_life_days', $data ?? [], null); + $this->setIfExists('life_time_days', $data ?? [], null); + $this->setIfExists('guarantee_period_days', $data ?? [], null); + $this->setIfExists('processing_state', $data ?? [], null); + $this->setIfExists('availability', $data ?? [], null); + $this->setIfExists('shelf_life', $data ?? [], null); + $this->setIfExists('life_time', $data ?? [], null); + $this->setIfExists('guarantee_period', $data ?? [], null); + $this->setIfExists('certificate', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('market_category_id', $data ?? [], null); + $this->setIfExists('market_category_name', $data ?? [], null); + $this->setIfExists('market_model_id', $data ?? [], null); + $this->setIfExists('market_model_name', $data ?? [], null); + $this->setIfExists('market_sku', $data ?? [], null); + $this->setIfExists('market_sku_name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 256)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 6000)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 6000."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 255)) { + $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) < 1)) { + $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['id'])) { + $invalidProperties[] = "invalid value for 'id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Составляйте название по схеме: тип + бренд или производитель + модель + особенности, если есть (например, цвет, размер или вес) и количество в упаковке. Не включайте в название условия продажи (например, «скидка», «бесплатная доставка» и т. д.), эмоциональные характеристики («хит», «супер» и т. д.). Не пишите слова большими буквами — кроме устоявшихся названий брендов и моделей. Оптимальная длина — 50–60 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/title.html) + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + if ((mb_strlen($name) > 256)) { + throw new \InvalidArgumentException('invalid length for $name when calling EnrichedMappingsOfferDTO., must be smaller than or equal to 256.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets shop_sku + * + * @return string|null + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string|null $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling EnrichedMappingsOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling EnrichedMappingsOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling EnrichedMappingsOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category Категория товара в вашем магазине. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. Указывайте конкретные категории — например, набор ножей лучше отнести к категории **Столовые приборы**, а не просто **Посуда**. Выбирайте категории, которые описывают товар, а не абстрактный признак — например, **Духи**, а не **Подарки**. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. + * + * @return self + */ + public function setCategory($category) + { + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets vendor + * + * @return string|null + */ + public function getVendor() + { + return $this->container['vendor']; + } + + /** + * Sets vendor + * + * @param string|null $vendor Название бренда или производителя. Должно быть записано так, как его пишет сам бренд. + * + * @return self + */ + public function setVendor($vendor) + { + if (is_null($vendor)) { + throw new \InvalidArgumentException('non-nullable vendor cannot be null'); + } + $this->container['vendor'] = $vendor; + + return $this; + } + + /** + * Gets vendor_code + * + * @return string|null + */ + public function getVendorCode() + { + return $this->container['vendor_code']; + } + + /** + * Sets vendor_code + * + * @param string|null $vendor_code Артикул товара от производителя. + * + * @return self + */ + public function setVendorCode($vendor_code) + { + if (is_null($vendor_code)) { + throw new \InvalidArgumentException('non-nullable vendor_code cannot be null'); + } + $this->container['vendor_code'] = $vendor_code; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Подробное описание товара: например, его преимущества и особенности. Не давайте в описании инструкций по установке и сборке. Не используйте слова «скидка», «распродажа», «дешевый», «подарок» (кроме подарочных категорий), «бесплатно», «акция», «специальная цена», «новинка», «new», «аналог», «заказ», «хит». Не указывайте никакой контактной информации и не давайте ссылок. Можно использовать теги: * \\, \\

          , \\

          и так далее — для заголовков; * \\
          и \\

          — для переноса строки; * \\

            — для нумерованного списка; * \\
              — для маркированного списка; * \\
            • — для создания элементов списка (должен находиться внутри \\
                или \\
                  ); * \\
                  — поддерживается, но не влияет на отображение текста. Оптимальная длина — 400–600 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/description.html) + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + if ((mb_strlen($description) > 6000)) { + throw new \InvalidArgumentException('invalid length for $description when calling EnrichedMappingsOfferDTO., must be smaller than or equal to 6000.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + if ((mb_strlen($id) > 255)) { + throw new \InvalidArgumentException('invalid length for $id when calling EnrichedMappingsOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($id) < 1)) { + throw new \InvalidArgumentException('invalid length for $id when calling EnrichedMappingsOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($id)))) { + throw new \InvalidArgumentException("invalid value for \$id when calling EnrichedMappingsOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets feed_id + * + * @return int|null + */ + public function getFeedId() + { + return $this->container['feed_id']; + } + + /** + * Sets feed_id + * + * @param int|null $feed_id Идентификатор фида. + * + * @return self + */ + public function setFeedId($feed_id) + { + if (is_null($feed_id)) { + throw new \InvalidArgumentException('non-nullable feed_id cannot be null'); + } + $this->container['feed_id'] = $feed_id; + + return $this; + } + + /** + * Gets barcodes + * + * @return string[]|null + */ + public function getBarcodes() + { + return $this->container['barcodes']; + } + + /** + * Sets barcodes + * + * @param string[]|null $barcodes Указывайте в виде последовательности цифр. Подойдут коды EAN-13, EAN-8, UPC-A, UPC-E или Code 128. Для книг указывайте ISBN. Для товаров [определенных категорий и торговых марок](https://yastatic.net/s3/doc-binary/src/support/market/ru/yandex-market-list-for-gtin.xlsx) штрихкод должен быть действительным кодом GTIN. Обратите внимание: внутренние штрихкоды, начинающиеся на 2 или 02, и коды формата Code 128 не являются GTIN. [Что такое GTIN](*gtin) + * + * @return self + */ + public function setBarcodes($barcodes) + { + if (is_null($barcodes)) { + array_push($this->openAPINullablesSetToNull, 'barcodes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('barcodes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['barcodes'] = $barcodes; + + return $this; + } + + /** + * Gets urls + * + * @return string[]|null + */ + public function getUrls() + { + return $this->container['urls']; + } + + /** + * Sets urls + * + * @param string[]|null $urls URL фотографии товара или страницы с описанием на вашем сайте. Переданные данные не будут отображаться на витрине, но они помогут специалистам Маркета найти карточку для вашего товара. Должен содержать один вложенный параметр url. + * + * @return self + */ + public function setUrls($urls) + { + if (is_null($urls)) { + array_push($this->openAPINullablesSetToNull, 'urls'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('urls', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['urls'] = $urls; + + return $this; + } + + /** + * Gets pictures + * + * @return string[]|null + */ + public function getPictures() + { + return $this->container['pictures']; + } + + /** + * Sets pictures + * + * @param string[]|null $pictures Ссылки (URL) изображений товара в хорошем качестве. Можно указать до 30 ссылок. При этом изображение по первой ссылке будет основным. Оно используется в качестве изображения товара в поиске Маркета и на карточке товара. Другие изображения товара доступны в режиме просмотра увеличенных изображений. Обязательный параметр. Должен содержать хотя бы один вложенный параметр `picture`. + * + * @return self + */ + public function setPictures($pictures) + { + if (is_null($pictures)) { + array_push($this->openAPINullablesSetToNull, 'pictures'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('pictures', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['pictures'] = $pictures; + + return $this; + } + + /** + * Gets manufacturer + * + * @return string|null + */ + public function getManufacturer() + { + return $this->container['manufacturer']; + } + + /** + * Sets manufacturer + * + * @param string|null $manufacturer Изготовитель товара: компания, которая произвела товар, ее адрес и регистрационный номер (если есть). Необязательный параметр. + * + * @return self + */ + public function setManufacturer($manufacturer) + { + if (is_null($manufacturer)) { + throw new \InvalidArgumentException('non-nullable manufacturer cannot be null'); + } + $this->container['manufacturer'] = $manufacturer; + + return $this; + } + + /** + * Gets manufacturer_countries + * + * @return string[]|null + */ + public function getManufacturerCountries() + { + return $this->container['manufacturer_countries']; + } + + /** + * Sets manufacturer_countries + * + * @param string[]|null $manufacturer_countries Список стран, в которых произведен товар. Обязательный параметр. Должен содержать хотя бы одну, но не больше 5 стран. + * + * @return self + */ + public function setManufacturerCountries($manufacturer_countries) + { + if (is_null($manufacturer_countries)) { + array_push($this->openAPINullablesSetToNull, 'manufacturer_countries'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manufacturer_countries', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['manufacturer_countries'] = $manufacturer_countries; + + return $this; + } + + /** + * Gets min_shipment + * + * @return int|null + */ + public function getMinShipment() + { + return $this->container['min_shipment']; + } + + /** + * Sets min_shipment + * + * @param int|null $min_shipment Минимальное количество единиц товара, которое вы поставляете на склад. Например, если вы поставляете детское питание партиями минимум по 10 коробок, а в каждой коробке по 6 баночек, укажите значение 60. + * + * @return self + */ + public function setMinShipment($min_shipment) + { + if (is_null($min_shipment)) { + throw new \InvalidArgumentException('non-nullable min_shipment cannot be null'); + } + $this->container['min_shipment'] = $min_shipment; + + return $this; + } + + /** + * Gets transport_unit_size + * + * @return int|null + */ + public function getTransportUnitSize() + { + return $this->container['transport_unit_size']; + } + + /** + * Sets transport_unit_size + * + * @param int|null $transport_unit_size Количество единиц товара в одной упаковке, которую вы поставляете на склад. Например, если вы поставляете детское питание коробками по 6 баночек, укажите значение 6. + * + * @return self + */ + public function setTransportUnitSize($transport_unit_size) + { + if (is_null($transport_unit_size)) { + throw new \InvalidArgumentException('non-nullable transport_unit_size cannot be null'); + } + $this->container['transport_unit_size'] = $transport_unit_size; + + return $this; + } + + /** + * Gets quantum_of_supply + * + * @return int|null + */ + public function getQuantumOfSupply() + { + return $this->container['quantum_of_supply']; + } + + /** + * Sets quantum_of_supply + * + * @param int|null $quantum_of_supply Добавочная партия: по сколько единиц товара можно добавлять к минимальному количеству minShipment. Например, если вы поставляете детское питание партиями минимум по 10 коробок и хотите добавлять к минимальной партии по 2 коробки, а в каждой коробке по 6 баночек, укажите значение 12. + * + * @return self + */ + public function setQuantumOfSupply($quantum_of_supply) + { + if (is_null($quantum_of_supply)) { + throw new \InvalidArgumentException('non-nullable quantum_of_supply cannot be null'); + } + $this->container['quantum_of_supply'] = $quantum_of_supply; + + return $this; + } + + /** + * Gets delivery_duration_days + * + * @return int|null + */ + public function getDeliveryDurationDays() + { + return $this->container['delivery_duration_days']; + } + + /** + * Sets delivery_duration_days + * + * @param int|null $delivery_duration_days Срок, за который продавец поставляет товары на склад, в днях. + * + * @return self + */ + public function setDeliveryDurationDays($delivery_duration_days) + { + if (is_null($delivery_duration_days)) { + throw new \InvalidArgumentException('non-nullable delivery_duration_days cannot be null'); + } + $this->container['delivery_duration_days'] = $delivery_duration_days; + + return $this; + } + + /** + * Gets box_count + * + * @return int|null + */ + public function getBoxCount() + { + return $this->container['box_count']; + } + + /** + * Sets box_count + * + * @param int|null $box_count Сколько мест (если больше одного) занимает товар. Параметр указывается, только если товар занимает больше одного места (например, кондиционер занимает два места: внешний и внутренний блоки в двух коробках). Если товар занимает одно место, не указывайте этот параметр. + * + * @return self + */ + public function setBoxCount($box_count) + { + if (is_null($box_count)) { + throw new \InvalidArgumentException('non-nullable box_count cannot be null'); + } + $this->container['box_count'] = $box_count; + + return $this; + } + + /** + * Gets customs_commodity_codes + * + * @return string[]|null + */ + public function getCustomsCommodityCodes() + { + return $this->container['customs_commodity_codes']; + } + + /** + * Sets customs_commodity_codes + * + * @param string[]|null $customs_commodity_codes Список кодов товара в единой Товарной номенклатуре внешнеэкономической деятельности (ТН ВЭД). Обязательный параметр, если товар подлежит особому учету (например, в системе «Меркурий» как продукция животного происхождения или в системе «Честный ЗНАК»). Может содержать только один вложенный код ТН ВЭД. + * + * @return self + */ + public function setCustomsCommodityCodes($customs_commodity_codes) + { + if (is_null($customs_commodity_codes)) { + array_push($this->openAPINullablesSetToNull, 'customs_commodity_codes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('customs_commodity_codes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['customs_commodity_codes'] = $customs_commodity_codes; + + return $this; + } + + /** + * Gets weight_dimensions + * + * @return \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null + */ + public function getWeightDimensions() + { + return $this->container['weight_dimensions']; + } + + /** + * Sets weight_dimensions + * + * @param \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null $weight_dimensions weight_dimensions + * + * @return self + */ + public function setWeightDimensions($weight_dimensions) + { + if (is_null($weight_dimensions)) { + throw new \InvalidArgumentException('non-nullable weight_dimensions cannot be null'); + } + $this->container['weight_dimensions'] = $weight_dimensions; + + return $this; + } + + /** + * Gets supply_schedule_days + * + * @return \OpenAPI\Client\Model\DayOfWeekType[]|null + */ + public function getSupplyScheduleDays() + { + return $this->container['supply_schedule_days']; + } + + /** + * Sets supply_schedule_days + * + * @param \OpenAPI\Client\Model\DayOfWeekType[]|null $supply_schedule_days Дни недели, в которые продавец поставляет товары на склад. + * + * @return self + */ + public function setSupplyScheduleDays($supply_schedule_days) + { + if (is_null($supply_schedule_days)) { + array_push($this->openAPINullablesSetToNull, 'supply_schedule_days'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('supply_schedule_days', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['supply_schedule_days'] = $supply_schedule_days; + + return $this; + } + + /** + * Gets shelf_life_days + * + * @return int|null + */ + public function getShelfLifeDays() + { + return $this->container['shelf_life_days']; + } + + /** + * Sets shelf_life_days + * + * @param int|null $shelf_life_days {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `shelfLife`. Совместное использование обоих параметров приведет к ошибке. {% endnote %} Срок годности: через сколько дней товар станет непригоден для использования. + * + * @return self + */ + public function setShelfLifeDays($shelf_life_days) + { + if (is_null($shelf_life_days)) { + throw new \InvalidArgumentException('non-nullable shelf_life_days cannot be null'); + } + $this->container['shelf_life_days'] = $shelf_life_days; + + return $this; + } + + /** + * Gets life_time_days + * + * @return int|null + */ + public function getLifeTimeDays() + { + return $this->container['life_time_days']; + } + + /** + * Sets life_time_days + * + * @param int|null $life_time_days {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `lifeTime`. Совместное использование обоих параметров приведет к ошибке. {% endnote %} Срок службы: сколько дней товар будет исправно выполнять свою функцию, а изготовитель — нести ответственность за его существенные недостатки. + * + * @return self + */ + public function setLifeTimeDays($life_time_days) + { + if (is_null($life_time_days)) { + throw new \InvalidArgumentException('non-nullable life_time_days cannot be null'); + } + $this->container['life_time_days'] = $life_time_days; + + return $this; + } + + /** + * Gets guarantee_period_days + * + * @return int|null + */ + public function getGuaranteePeriodDays() + { + return $this->container['guarantee_period_days']; + } + + /** + * Sets guarantee_period_days + * + * @param int|null $guarantee_period_days Гарантийный срок товара: сколько дней возможно обслуживание и ремонт товара или возврат денег, а изготовитель или продавец будет нести ответственность за недостатки товара. + * + * @return self + */ + public function setGuaranteePeriodDays($guarantee_period_days) + { + if (is_null($guarantee_period_days)) { + throw new \InvalidArgumentException('non-nullable guarantee_period_days cannot be null'); + } + $this->container['guarantee_period_days'] = $guarantee_period_days; + + return $this; + } + + /** + * Gets processing_state + * + * @return \OpenAPI\Client\Model\OfferProcessingStateDTO|null + */ + public function getProcessingState() + { + return $this->container['processing_state']; + } + + /** + * Sets processing_state + * + * @param \OpenAPI\Client\Model\OfferProcessingStateDTO|null $processing_state processing_state + * + * @return self + */ + public function setProcessingState($processing_state) + { + if (is_null($processing_state)) { + throw new \InvalidArgumentException('non-nullable processing_state cannot be null'); + } + $this->container['processing_state'] = $processing_state; + + return $this; + } + + /** + * Gets availability + * + * @return \OpenAPI\Client\Model\OfferAvailabilityStatusType|null + */ + public function getAvailability() + { + return $this->container['availability']; + } + + /** + * Sets availability + * + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType|null $availability availability + * + * @return self + */ + public function setAvailability($availability) + { + if (is_null($availability)) { + throw new \InvalidArgumentException('non-nullable availability cannot be null'); + } + $this->container['availability'] = $availability; + + return $this; + } + + /** + * Gets shelf_life + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getShelfLife() + { + return $this->container['shelf_life']; + } + + /** + * Sets shelf_life + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $shelf_life shelf_life + * + * @return self + */ + public function setShelfLife($shelf_life) + { + if (is_null($shelf_life)) { + throw new \InvalidArgumentException('non-nullable shelf_life cannot be null'); + } + $this->container['shelf_life'] = $shelf_life; + + return $this; + } + + /** + * Gets life_time + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getLifeTime() + { + return $this->container['life_time']; + } + + /** + * Sets life_time + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $life_time life_time + * + * @return self + */ + public function setLifeTime($life_time) + { + if (is_null($life_time)) { + throw new \InvalidArgumentException('non-nullable life_time cannot be null'); + } + $this->container['life_time'] = $life_time; + + return $this; + } + + /** + * Gets guarantee_period + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getGuaranteePeriod() + { + return $this->container['guarantee_period']; + } + + /** + * Sets guarantee_period + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $guarantee_period guarantee_period + * + * @return self + */ + public function setGuaranteePeriod($guarantee_period) + { + if (is_null($guarantee_period)) { + throw new \InvalidArgumentException('non-nullable guarantee_period cannot be null'); + } + $this->container['guarantee_period'] = $guarantee_period; + + return $this; + } + + /** + * Gets certificate + * + * @return string|null + */ + public function getCertificate() + { + return $this->container['certificate']; + } + + /** + * Sets certificate + * + * @param string|null $certificate Номер документа на товар. Перед указанием номера документ нужно загрузить в кабинете продавца на Маркете. [Инструкция](https://yandex.ru/support/marketplace/assortment/restrictions/certificates.html) + * + * @return self + */ + public function setCertificate($certificate) + { + if (is_null($certificate)) { + throw new \InvalidArgumentException('non-nullable certificate cannot be null'); + } + $this->container['certificate'] = $certificate; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price Цена на товар в рублях. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets market_category_id + * + * @return int|null + */ + public function getMarketCategoryId() + { + return $this->container['market_category_id']; + } + + /** + * Sets market_category_id + * + * @param int|null $market_category_id Идентификатор категории для рекомендованной карточки товара на Маркете. Возвращается только вместе с параметром ##marketSku##. + * + * @return self + */ + public function setMarketCategoryId($market_category_id) + { + if (is_null($market_category_id)) { + throw new \InvalidArgumentException('non-nullable market_category_id cannot be null'); + } + $this->container['market_category_id'] = $market_category_id; + + return $this; + } + + /** + * Gets market_category_name + * + * @return string|null + */ + public function getMarketCategoryName() + { + return $this->container['market_category_name']; + } + + /** + * Sets market_category_name + * + * @param string|null $market_category_name Название категории для рекомендованной карточки товара на Маркете. Может отсутствовать в ответе. + * + * @return self + */ + public function setMarketCategoryName($market_category_name) + { + if (is_null($market_category_name)) { + throw new \InvalidArgumentException('non-nullable market_category_name cannot be null'); + } + $this->container['market_category_name'] = $market_category_name; + + return $this; + } + + /** + * Gets market_model_id + * + * @return int|null + */ + public function getMarketModelId() + { + return $this->container['market_model_id']; + } + + /** + * Sets market_model_id + * + * @param int|null $market_model_id Идентификатор модели для рекомендованной карточки товара на Маркете. Может отсутствовать в ответе. + * + * @return self + */ + public function setMarketModelId($market_model_id) + { + if (is_null($market_model_id)) { + throw new \InvalidArgumentException('non-nullable market_model_id cannot be null'); + } + $this->container['market_model_id'] = $market_model_id; + + return $this; + } + + /** + * Gets market_model_name + * + * @return string|null + */ + public function getMarketModelName() + { + return $this->container['market_model_name']; + } + + /** + * Sets market_model_name + * + * @param string|null $market_model_name Название модели для рекомендованной карточки товара на Маркете. Возвращается только вместе с параметром ##marketSku##. + * + * @return self + */ + public function setMarketModelName($market_model_name) + { + if (is_null($market_model_name)) { + throw new \InvalidArgumentException('non-nullable market_model_name cannot be null'); + } + $this->container['market_model_name'] = $market_model_name; + + return $this; + } + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling EnrichedMappingsOfferDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + + /** + * Gets market_sku_name + * + * @return string|null + */ + public function getMarketSkuName() + { + return $this->container['market_sku_name']; + } + + /** + * Sets market_sku_name + * + * @param string|null $market_sku_name Название товара с рекомендованной карточки на Маркете. Может отсутствовать в ответе. + * + * @return self + */ + public function setMarketSkuName($market_sku_name) + { + if (is_null($market_sku_name)) { + throw new \InvalidArgumentException('non-nullable market_sku_name cannot be null'); + } + $this->container['market_sku_name'] = $market_sku_name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/EnrichedModelDTO.php b/erp24/lib/yandex_market_api/Model/EnrichedModelDTO.php new file mode 100644 index 00000000..1f3c397b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/EnrichedModelDTO.php @@ -0,0 +1,587 @@ + + */ +class EnrichedModelDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'EnrichedModelDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'prices' => '\OpenAPI\Client\Model\ModelPriceDTO', + 'offers' => '\OpenAPI\Client\Model\ModelOfferDTO[]', + 'offline_offers' => 'int', + 'online_offers' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'prices' => null, + 'offers' => null, + 'offline_offers' => 'int32', + 'online_offers' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'prices' => false, + 'offers' => true, + 'offline_offers' => false, + 'online_offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'prices' => 'prices', + 'offers' => 'offers', + 'offline_offers' => 'offlineOffers', + 'online_offers' => 'onlineOffers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'prices' => 'setPrices', + 'offers' => 'setOffers', + 'offline_offers' => 'setOfflineOffers', + 'online_offers' => 'setOnlineOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'prices' => 'getPrices', + 'offers' => 'getOffers', + 'offline_offers' => 'getOfflineOffers', + 'online_offers' => 'getOnlineOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('prices', $data ?? [], null); + $this->setIfExists('offers', $data ?? [], null); + $this->setIfExists('offline_offers', $data ?? [], null); + $this->setIfExists('online_offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор модели товара. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название модели товара. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets prices + * + * @return \OpenAPI\Client\Model\ModelPriceDTO|null + */ + public function getPrices() + { + return $this->container['prices']; + } + + /** + * Sets prices + * + * @param \OpenAPI\Client\Model\ModelPriceDTO|null $prices prices + * + * @return self + */ + public function setPrices($prices) + { + if (is_null($prices)) { + throw new \InvalidArgumentException('non-nullable prices cannot be null'); + } + $this->container['prices'] = $prices; + + return $this; + } + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\ModelOfferDTO[]|null + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\ModelOfferDTO[]|null $offers Список первых десяти предложений, расположенных на карточке модели. В ответе на запрос возвращаются предложения различных магазинов. Если есть несколько предложений от одного магазина, в ответе отображается только одно, наиболее релевантное из них. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + array_push($this->openAPINullablesSetToNull, 'offers'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offers', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['offers'] = $offers; + + return $this; + } + + /** + * Gets offline_offers + * + * @return int|null + */ + public function getOfflineOffers() + { + return $this->container['offline_offers']; + } + + /** + * Sets offline_offers + * + * @param int|null $offline_offers Суммарное количество предложений в розничных магазинах в регионе. Учитываются все предложения от каждого магазина. + * + * @return self + */ + public function setOfflineOffers($offline_offers) + { + if (is_null($offline_offers)) { + throw new \InvalidArgumentException('non-nullable offline_offers cannot be null'); + } + $this->container['offline_offers'] = $offline_offers; + + return $this; + } + + /** + * Gets online_offers + * + * @return int|null + */ + public function getOnlineOffers() + { + return $this->container['online_offers']; + } + + /** + * Sets online_offers + * + * @param int|null $online_offers Суммарное количество предложений в интернет-магазинах в регионе. Учитываются все предложения от каждого магазина. + * + * @return self + */ + public function setOnlineOffers($online_offers) + { + if (is_null($online_offers)) { + throw new \InvalidArgumentException('non-nullable online_offers cannot be null'); + } + $this->container['online_offers'] = $online_offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/EnrichedModelsDTO.php b/erp24/lib/yandex_market_api/Model/EnrichedModelsDTO.php new file mode 100644 index 00000000..2378cbb0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/EnrichedModelsDTO.php @@ -0,0 +1,413 @@ + + */ +class EnrichedModelsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'EnrichedModelsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'models' => '\OpenAPI\Client\Model\EnrichedModelDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'models' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'models' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'models' => 'models' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'models' => 'setModels' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'models' => 'getModels' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('models', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['models'] === null) { + $invalidProperties[] = "'models' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets models + * + * @return \OpenAPI\Client\Model\EnrichedModelDTO[] + */ + public function getModels() + { + return $this->container['models']; + } + + /** + * Sets models + * + * @param \OpenAPI\Client\Model\EnrichedModelDTO[] $models Список моделей товаров. + * + * @return self + */ + public function setModels($models) + { + if (is_null($models)) { + throw new \InvalidArgumentException('non-nullable models cannot be null'); + } + $this->container['models'] = $models; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/EnrichedOrderBoxLayoutDTO.php b/erp24/lib/yandex_market_api/Model/EnrichedOrderBoxLayoutDTO.php new file mode 100644 index 00000000..d39d09bd --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/EnrichedOrderBoxLayoutDTO.php @@ -0,0 +1,456 @@ + + */ +class EnrichedOrderBoxLayoutDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'EnrichedOrderBoxLayoutDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\OpenAPI\Client\Model\OrderBoxLayoutItemDTO[]', + 'box_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'box_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'items' => false, + 'box_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'box_id' => 'boxId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'box_id' => 'setBoxId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'box_id' => 'getBoxId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('items', $data ?? [], null); + $this->setIfExists('box_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + if ((count($this->container['items']) < 1)) { + $invalidProperties[] = "invalid value for 'items', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\OrderBoxLayoutItemDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\OrderBoxLayoutItemDTO[] $items Список товаров в коробке. Если в коробке едет часть большого товара, в списке может быть только один пункт. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + + + if ((count($items) < 1)) { + throw new \InvalidArgumentException('invalid length for $items when calling EnrichedOrderBoxLayoutDTO., number of items must be greater than or equal to 1.'); + } + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets box_id + * + * @return int|null + */ + public function getBoxId() + { + return $this->container['box_id']; + } + + /** + * Sets box_id + * + * @param int|null $box_id Идентификатор коробки. + * + * @return self + */ + public function setBoxId($box_id) + { + if (is_null($box_id)) { + throw new \InvalidArgumentException('non-nullable box_id cannot be null'); + } + $this->container['box_id'] = $box_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ExtensionShipmentDTO.php b/erp24/lib/yandex_market_api/Model/ExtensionShipmentDTO.php new file mode 100644 index 00000000..57eb9825 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ExtensionShipmentDTO.php @@ -0,0 +1,449 @@ + + */ +class ExtensionShipmentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ExtensionShipmentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'current_status' => '\OpenAPI\Client\Model\ShipmentStatusChangeDTO', + 'available_actions' => '\OpenAPI\Client\Model\ShipmentActionType[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'current_status' => null, + 'available_actions' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'current_status' => false, + 'available_actions' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'current_status' => 'currentStatus', + 'available_actions' => 'availableActions' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'current_status' => 'setCurrentStatus', + 'available_actions' => 'setAvailableActions' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'current_status' => 'getCurrentStatus', + 'available_actions' => 'getAvailableActions' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('current_status', $data ?? [], null); + $this->setIfExists('available_actions', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['available_actions'] === null) { + $invalidProperties[] = "'available_actions' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets current_status + * + * @return \OpenAPI\Client\Model\ShipmentStatusChangeDTO|null + */ + public function getCurrentStatus() + { + return $this->container['current_status']; + } + + /** + * Sets current_status + * + * @param \OpenAPI\Client\Model\ShipmentStatusChangeDTO|null $current_status current_status + * + * @return self + */ + public function setCurrentStatus($current_status) + { + if (is_null($current_status)) { + throw new \InvalidArgumentException('non-nullable current_status cannot be null'); + } + $this->container['current_status'] = $current_status; + + return $this; + } + + /** + * Gets available_actions + * + * @return \OpenAPI\Client\Model\ShipmentActionType[] + */ + public function getAvailableActions() + { + return $this->container['available_actions']; + } + + /** + * Sets available_actions + * + * @param \OpenAPI\Client\Model\ShipmentActionType[] $available_actions Доступные действия над отгрузкой. + * + * @return self + */ + public function setAvailableActions($available_actions) + { + if (is_null($available_actions)) { + throw new \InvalidArgumentException('non-nullable available_actions cannot be null'); + } + + + $this->container['available_actions'] = $available_actions; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedContentDTO.php b/erp24/lib/yandex_market_api/Model/FeedContentDTO.php new file mode 100644 index 00000000..29923c43 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedContentDTO.php @@ -0,0 +1,512 @@ + + */ +class FeedContentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedContentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rejected_offers_count' => 'int', + 'status' => '\OpenAPI\Client\Model\FeedStatusType', + 'total_offers_count' => 'int', + 'error' => '\OpenAPI\Client\Model\FeedContentErrorDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rejected_offers_count' => 'int64', + 'status' => null, + 'total_offers_count' => 'int64', + 'error' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rejected_offers_count' => false, + 'status' => false, + 'total_offers_count' => false, + 'error' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rejected_offers_count' => 'rejectedOffersCount', + 'status' => 'status', + 'total_offers_count' => 'totalOffersCount', + 'error' => 'error' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rejected_offers_count' => 'setRejectedOffersCount', + 'status' => 'setStatus', + 'total_offers_count' => 'setTotalOffersCount', + 'error' => 'setError' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rejected_offers_count' => 'getRejectedOffersCount', + 'status' => 'getStatus', + 'total_offers_count' => 'getTotalOffersCount', + 'error' => 'getError' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('rejected_offers_count', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('total_offers_count', $data ?? [], null); + $this->setIfExists('error', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets rejected_offers_count + * + * @return int|null + */ + public function getRejectedOffersCount() + { + return $this->container['rejected_offers_count']; + } + + /** + * Sets rejected_offers_count + * + * @param int|null $rejected_offers_count Количество предложений, в которых найдены ошибки на этапе загрузки прайс-листа. Выводится, если параметр `content status=OK`. + * + * @return self + */ + public function setRejectedOffersCount($rejected_offers_count) + { + if (is_null($rejected_offers_count)) { + throw new \InvalidArgumentException('non-nullable rejected_offers_count cannot be null'); + } + $this->container['rejected_offers_count'] = $rejected_offers_count; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\FeedStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\FeedStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets total_offers_count + * + * @return int|null + */ + public function getTotalOffersCount() + { + return $this->container['total_offers_count']; + } + + /** + * Sets total_offers_count + * + * @param int|null $total_offers_count Количество предложений в прайс-листе. Выводится, если параметр `content status=OK`. + * + * @return self + */ + public function setTotalOffersCount($total_offers_count) + { + if (is_null($total_offers_count)) { + throw new \InvalidArgumentException('non-nullable total_offers_count cannot be null'); + } + $this->container['total_offers_count'] = $total_offers_count; + + return $this; + } + + /** + * Gets error + * + * @return \OpenAPI\Client\Model\FeedContentErrorDTO|null + */ + public function getError() + { + return $this->container['error']; + } + + /** + * Sets error + * + * @param \OpenAPI\Client\Model\FeedContentErrorDTO|null $error error + * + * @return self + */ + public function setError($error) + { + if (is_null($error)) { + throw new \InvalidArgumentException('non-nullable error cannot be null'); + } + $this->container['error'] = $error; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedContentErrorDTO.php b/erp24/lib/yandex_market_api/Model/FeedContentErrorDTO.php new file mode 100644 index 00000000..a301a5b8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedContentErrorDTO.php @@ -0,0 +1,410 @@ + + */ +class FeedContentErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedContentErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\FeedContentErrorType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\FeedContentErrorType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\FeedContentErrorType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedContentErrorType.php b/erp24/lib/yandex_market_api/Model/FeedContentErrorType.php new file mode 100644 index 00000000..c4657dc2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedContentErrorType.php @@ -0,0 +1,66 @@ + + */ +class FeedDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'login' => 'string', + 'name' => 'string', + 'password' => 'string', + 'upload_date' => '\DateTime', + 'url' => 'string', + 'content' => '\OpenAPI\Client\Model\FeedContentDTO', + 'download' => '\OpenAPI\Client\Model\FeedDownloadDTO', + 'placement' => '\OpenAPI\Client\Model\FeedPlacementDTO', + 'publication' => '\OpenAPI\Client\Model\FeedPublicationDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'login' => null, + 'name' => null, + 'password' => null, + 'upload_date' => 'date-time', + 'url' => null, + 'content' => null, + 'download' => null, + 'placement' => null, + 'publication' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'login' => false, + 'name' => false, + 'password' => false, + 'upload_date' => false, + 'url' => false, + 'content' => false, + 'download' => false, + 'placement' => false, + 'publication' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'login' => 'login', + 'name' => 'name', + 'password' => 'password', + 'upload_date' => 'uploadDate', + 'url' => 'url', + 'content' => 'content', + 'download' => 'download', + 'placement' => 'placement', + 'publication' => 'publication' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'login' => 'setLogin', + 'name' => 'setName', + 'password' => 'setPassword', + 'upload_date' => 'setUploadDate', + 'url' => 'setUrl', + 'content' => 'setContent', + 'download' => 'setDownload', + 'placement' => 'setPlacement', + 'publication' => 'setPublication' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'login' => 'getLogin', + 'name' => 'getName', + 'password' => 'getPassword', + 'upload_date' => 'getUploadDate', + 'url' => 'getUrl', + 'content' => 'getContent', + 'download' => 'getDownload', + 'placement' => 'getPlacement', + 'publication' => 'getPublication' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('login', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('password', $data ?? [], null); + $this->setIfExists('upload_date', $data ?? [], null); + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('content', $data ?? [], null); + $this->setIfExists('download', $data ?? [], null); + $this->setIfExists('placement', $data ?? [], null); + $this->setIfExists('publication', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор прайс-листа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets login + * + * @return string|null + */ + public function getLogin() + { + return $this->container['login']; + } + + /** + * Sets login + * + * @param string|null $login Логин для авторизации при скачивании прайс-листа. Параметр выводится при размещении прайс-листа на сайте магазина и в случае ограничения доступа к нему. + * + * @return self + */ + public function setLogin($login) + { + if (is_null($login)) { + throw new \InvalidArgumentException('non-nullable login cannot be null'); + } + $this->container['login'] = $login; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Имя файла, содержащего прайс-лист. Параметр выводится при размещении прайс-листа на сервере Маркета. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets password + * + * @return string|null + */ + public function getPassword() + { + return $this->container['password']; + } + + /** + * Sets password + * + * @param string|null $password Пароль для авторизации при скачивании прайс-листа. Параметр выводится при размещении прайс-листа на сайте магазина и в случае ограничения доступа к нему. + * + * @return self + */ + public function setPassword($password) + { + if (is_null($password)) { + throw new \InvalidArgumentException('non-nullable password cannot be null'); + } + $this->container['password'] = $password; + + return $this; + } + + /** + * Gets upload_date + * + * @return \DateTime|null + */ + public function getUploadDate() + { + return $this->container['upload_date']; + } + + /** + * Sets upload_date + * + * @param \DateTime|null $upload_date Дата загрузки прайс-листа на Маркет. Формат даты: `ДД-ММ-ГГГГ`. Параметр выводится при размещении прайс-листа на сервере Маркета. + * + * @return self + */ + public function setUploadDate($upload_date) + { + if (is_null($upload_date)) { + throw new \InvalidArgumentException('non-nullable upload_date cannot be null'); + } + $this->container['upload_date'] = $upload_date; + + return $this; + } + + /** + * Gets url + * + * @return string|null + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string|null $url URL прайс-листа. Параметр выводится при размещении прайс-листа на сайте магазина. + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets content + * + * @return \OpenAPI\Client\Model\FeedContentDTO|null + */ + public function getContent() + { + return $this->container['content']; + } + + /** + * Sets content + * + * @param \OpenAPI\Client\Model\FeedContentDTO|null $content content + * + * @return self + */ + public function setContent($content) + { + if (is_null($content)) { + throw new \InvalidArgumentException('non-nullable content cannot be null'); + } + $this->container['content'] = $content; + + return $this; + } + + /** + * Gets download + * + * @return \OpenAPI\Client\Model\FeedDownloadDTO|null + */ + public function getDownload() + { + return $this->container['download']; + } + + /** + * Sets download + * + * @param \OpenAPI\Client\Model\FeedDownloadDTO|null $download download + * + * @return self + */ + public function setDownload($download) + { + if (is_null($download)) { + throw new \InvalidArgumentException('non-nullable download cannot be null'); + } + $this->container['download'] = $download; + + return $this; + } + + /** + * Gets placement + * + * @return \OpenAPI\Client\Model\FeedPlacementDTO|null + */ + public function getPlacement() + { + return $this->container['placement']; + } + + /** + * Sets placement + * + * @param \OpenAPI\Client\Model\FeedPlacementDTO|null $placement placement + * + * @return self + */ + public function setPlacement($placement) + { + if (is_null($placement)) { + throw new \InvalidArgumentException('non-nullable placement cannot be null'); + } + $this->container['placement'] = $placement; + + return $this; + } + + /** + * Gets publication + * + * @return \OpenAPI\Client\Model\FeedPublicationDTO|null + */ + public function getPublication() + { + return $this->container['publication']; + } + + /** + * Sets publication + * + * @param \OpenAPI\Client\Model\FeedPublicationDTO|null $publication publication + * + * @return self + */ + public function setPublication($publication) + { + if (is_null($publication)) { + throw new \InvalidArgumentException('non-nullable publication cannot be null'); + } + $this->container['publication'] = $publication; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedDownloadDTO.php b/erp24/lib/yandex_market_api/Model/FeedDownloadDTO.php new file mode 100644 index 00000000..a321985d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedDownloadDTO.php @@ -0,0 +1,444 @@ + + */ +class FeedDownloadDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedDownloadDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\FeedStatusType', + 'error' => '\OpenAPI\Client\Model\FeedDownloadErrorDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'error' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'error' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'error' => 'error' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'error' => 'setError' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'error' => 'getError' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('error', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\FeedStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\FeedStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets error + * + * @return \OpenAPI\Client\Model\FeedDownloadErrorDTO|null + */ + public function getError() + { + return $this->container['error']; + } + + /** + * Sets error + * + * @param \OpenAPI\Client\Model\FeedDownloadErrorDTO|null $error error + * + * @return self + */ + public function setError($error) + { + if (is_null($error)) { + throw new \InvalidArgumentException('non-nullable error cannot be null'); + } + $this->container['error'] = $error; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedDownloadErrorDTO.php b/erp24/lib/yandex_market_api/Model/FeedDownloadErrorDTO.php new file mode 100644 index 00000000..aaed7f89 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedDownloadErrorDTO.php @@ -0,0 +1,478 @@ + + */ +class FeedDownloadErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedDownloadErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'http_status_code' => 'int', + 'type' => '\OpenAPI\Client\Model\FeedDownloadErrorType', + 'description' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'http_status_code' => 'int32', + 'type' => null, + 'description' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'http_status_code' => false, + 'type' => false, + 'description' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'http_status_code' => 'httpStatusCode', + 'type' => 'type', + 'description' => 'description' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'http_status_code' => 'setHttpStatusCode', + 'type' => 'setType', + 'description' => 'setDescription' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'http_status_code' => 'getHttpStatusCode', + 'type' => 'getType', + 'description' => 'getDescription' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('http_status_code', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets http_status_code + * + * @return int|null + */ + public function getHttpStatusCode() + { + return $this->container['http_status_code']; + } + + /** + * Sets http_status_code + * + * @param int|null $http_status_code HTTP-код ошибки индексации прайс-листа. Выводится, если `type=DOWNLOAD_HTTP_ERROR`. + * + * @return self + */ + public function setHttpStatusCode($http_status_code) + { + if (is_null($http_status_code)) { + throw new \InvalidArgumentException('non-nullable http_status_code cannot be null'); + } + $this->container['http_status_code'] = $http_status_code; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\FeedDownloadErrorType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\FeedDownloadErrorType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Описание ошибки. Выводится, если `type=DOWNLOAD_ERROR`. + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + $this->container['description'] = $description; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedDownloadErrorType.php b/erp24/lib/yandex_market_api/Model/FeedDownloadErrorType.php new file mode 100644 index 00000000..8a910063 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedDownloadErrorType.php @@ -0,0 +1,63 @@ + + */ +class FeedIndexLogsErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedIndexLogsErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'http_status_code' => 'int', + 'type' => '\OpenAPI\Client\Model\FeedIndexLogsErrorType', + 'description' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'http_status_code' => 'int32', + 'type' => null, + 'description' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'http_status_code' => false, + 'type' => false, + 'description' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'http_status_code' => 'httpStatusCode', + 'type' => 'type', + 'description' => 'description' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'http_status_code' => 'setHttpStatusCode', + 'type' => 'setType', + 'description' => 'setDescription' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'http_status_code' => 'getHttpStatusCode', + 'type' => 'getType', + 'description' => 'getDescription' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('http_status_code', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets http_status_code + * + * @return int|null + */ + public function getHttpStatusCode() + { + return $this->container['http_status_code']; + } + + /** + * Sets http_status_code + * + * @param int|null $http_status_code HTTP-код ошибки индексации прайс-листа. Выводится, если `type=DOWNLOAD_HTTP_ERROR`. + * + * @return self + */ + public function setHttpStatusCode($http_status_code) + { + if (is_null($http_status_code)) { + throw new \InvalidArgumentException('non-nullable http_status_code cannot be null'); + } + $this->container['http_status_code'] = $http_status_code; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\FeedIndexLogsErrorType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\FeedIndexLogsErrorType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Описание ошибки. Выводится, если `type=DOWNLOAD_ERROR`. + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + $this->container['description'] = $description; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedIndexLogsErrorType.php b/erp24/lib/yandex_market_api/Model/FeedIndexLogsErrorType.php new file mode 100644 index 00000000..1f140877 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedIndexLogsErrorType.php @@ -0,0 +1,75 @@ + + */ +class FeedIndexLogsFeedDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedIndexLogsFeedDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор прайс-листа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedIndexLogsIndexType.php b/erp24/lib/yandex_market_api/Model/FeedIndexLogsIndexType.php new file mode 100644 index 00000000..71748b0a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedIndexLogsIndexType.php @@ -0,0 +1,66 @@ + + */ +class FeedIndexLogsOffersDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedIndexLogsOffersDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rejected_count' => 'int', + 'total_count' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rejected_count' => 'int64', + 'total_count' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rejected_count' => false, + 'total_count' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rejected_count' => 'rejectedCount', + 'total_count' => 'totalCount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rejected_count' => 'setRejectedCount', + 'total_count' => 'setTotalCount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rejected_count' => 'getRejectedCount', + 'total_count' => 'getTotalCount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('rejected_count', $data ?? [], null); + $this->setIfExists('total_count', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets rejected_count + * + * @return int|null + */ + public function getRejectedCount() + { + return $this->container['rejected_count']; + } + + /** + * Sets rejected_count + * + * @param int|null $rejected_count Количество предложений, который не опубликованы на Маркете из-за найденных ошибок. + * + * @return self + */ + public function setRejectedCount($rejected_count) + { + if (is_null($rejected_count)) { + throw new \InvalidArgumentException('non-nullable rejected_count cannot be null'); + } + $this->container['rejected_count'] = $rejected_count; + + return $this; + } + + /** + * Gets total_count + * + * @return int|null + */ + public function getTotalCount() + { + return $this->container['total_count']; + } + + /** + * Sets total_count + * + * @param int|null $total_count Количество предложений в прайс-листе. + * + * @return self + */ + public function setTotalCount($total_count) + { + if (is_null($total_count)) { + throw new \InvalidArgumentException('non-nullable total_count cannot be null'); + } + $this->container['total_count'] = $total_count; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedIndexLogsRecordDTO.php b/erp24/lib/yandex_market_api/Model/FeedIndexLogsRecordDTO.php new file mode 100644 index 00000000..f6adf7c3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedIndexLogsRecordDTO.php @@ -0,0 +1,648 @@ + + */ +class FeedIndexLogsRecordDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedIndexLogsRecordDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'download_time' => '\DateTime', + 'file_time' => '\DateTime', + 'generation_id' => 'int', + 'index_type' => '\OpenAPI\Client\Model\FeedIndexLogsIndexType', + 'published_time' => '\DateTime', + 'status' => '\OpenAPI\Client\Model\FeedIndexLogsStatusType', + 'error' => '\OpenAPI\Client\Model\FeedIndexLogsErrorDTO', + 'offers' => '\OpenAPI\Client\Model\FeedIndexLogsOffersDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'download_time' => 'date-time', + 'file_time' => 'date-time', + 'generation_id' => 'int64', + 'index_type' => null, + 'published_time' => 'date-time', + 'status' => null, + 'error' => null, + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'download_time' => false, + 'file_time' => false, + 'generation_id' => false, + 'index_type' => false, + 'published_time' => false, + 'status' => false, + 'error' => false, + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'download_time' => 'downloadTime', + 'file_time' => 'fileTime', + 'generation_id' => 'generationId', + 'index_type' => 'indexType', + 'published_time' => 'publishedTime', + 'status' => 'status', + 'error' => 'error', + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'download_time' => 'setDownloadTime', + 'file_time' => 'setFileTime', + 'generation_id' => 'setGenerationId', + 'index_type' => 'setIndexType', + 'published_time' => 'setPublishedTime', + 'status' => 'setStatus', + 'error' => 'setError', + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'download_time' => 'getDownloadTime', + 'file_time' => 'getFileTime', + 'generation_id' => 'getGenerationId', + 'index_type' => 'getIndexType', + 'published_time' => 'getPublishedTime', + 'status' => 'getStatus', + 'error' => 'getError', + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('download_time', $data ?? [], null); + $this->setIfExists('file_time', $data ?? [], null); + $this->setIfExists('generation_id', $data ?? [], null); + $this->setIfExists('index_type', $data ?? [], null); + $this->setIfExists('published_time', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('error', $data ?? [], null); + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets download_time + * + * @return \DateTime|null + */ + public function getDownloadTime() + { + return $this->container['download_time']; + } + + /** + * Sets download_time + * + * @param \DateTime|null $download_time Дата и время загрузки прайс-листа. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setDownloadTime($download_time) + { + if (is_null($download_time)) { + throw new \InvalidArgumentException('non-nullable download_time cannot be null'); + } + $this->container['download_time'] = $download_time; + + return $this; + } + + /** + * Gets file_time + * + * @return \DateTime|null + */ + public function getFileTime() + { + return $this->container['file_time']; + } + + /** + * Sets file_time + * + * @param \DateTime|null $file_time Дата и время, которые магазин указал в прайс-листе. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setFileTime($file_time) + { + if (is_null($file_time)) { + throw new \InvalidArgumentException('non-nullable file_time cannot be null'); + } + $this->container['file_time'] = $file_time; + + return $this; + } + + /** + * Gets generation_id + * + * @return int|null + */ + public function getGenerationId() + { + return $this->container['generation_id']; + } + + /** + * Sets generation_id + * + * @param int|null $generation_id Идентификатор индексации. + * + * @return self + */ + public function setGenerationId($generation_id) + { + if (is_null($generation_id)) { + throw new \InvalidArgumentException('non-nullable generation_id cannot be null'); + } + $this->container['generation_id'] = $generation_id; + + return $this; + } + + /** + * Gets index_type + * + * @return \OpenAPI\Client\Model\FeedIndexLogsIndexType|null + */ + public function getIndexType() + { + return $this->container['index_type']; + } + + /** + * Sets index_type + * + * @param \OpenAPI\Client\Model\FeedIndexLogsIndexType|null $index_type index_type + * + * @return self + */ + public function setIndexType($index_type) + { + if (is_null($index_type)) { + throw new \InvalidArgumentException('non-nullable index_type cannot be null'); + } + $this->container['index_type'] = $index_type; + + return $this; + } + + /** + * Gets published_time + * + * @return \DateTime|null + */ + public function getPublishedTime() + { + return $this->container['published_time']; + } + + /** + * Sets published_time + * + * @param \DateTime|null $published_time Дата и время публикации предложений из прайс-листа на Яндекс Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setPublishedTime($published_time) + { + if (is_null($published_time)) { + throw new \InvalidArgumentException('non-nullable published_time cannot be null'); + } + $this->container['published_time'] = $published_time; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\FeedIndexLogsStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\FeedIndexLogsStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets error + * + * @return \OpenAPI\Client\Model\FeedIndexLogsErrorDTO|null + */ + public function getError() + { + return $this->container['error']; + } + + /** + * Sets error + * + * @param \OpenAPI\Client\Model\FeedIndexLogsErrorDTO|null $error error + * + * @return self + */ + public function setError($error) + { + if (is_null($error)) { + throw new \InvalidArgumentException('non-nullable error cannot be null'); + } + $this->container['error'] = $error; + + return $this; + } + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\FeedIndexLogsOffersDTO|null + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\FeedIndexLogsOffersDTO|null $offers offers + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedIndexLogsResultDTO.php b/erp24/lib/yandex_market_api/Model/FeedIndexLogsResultDTO.php new file mode 100644 index 00000000..85d0fcf9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedIndexLogsResultDTO.php @@ -0,0 +1,481 @@ + + */ +class FeedIndexLogsResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedIndexLogsResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feed' => '\OpenAPI\Client\Model\FeedIndexLogsFeedDTO', + 'index_log_records' => '\OpenAPI\Client\Model\FeedIndexLogsRecordDTO[]', + 'total' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feed' => null, + 'index_log_records' => null, + 'total' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feed' => false, + 'index_log_records' => false, + 'total' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'feed' => 'feed', + 'index_log_records' => 'indexLogRecords', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feed' => 'setFeed', + 'index_log_records' => 'setIndexLogRecords', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feed' => 'getFeed', + 'index_log_records' => 'getIndexLogRecords', + 'total' => 'getTotal' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('feed', $data ?? [], null); + $this->setIfExists('index_log_records', $data ?? [], null); + $this->setIfExists('total', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['index_log_records'] === null) { + $invalidProperties[] = "'index_log_records' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets feed + * + * @return \OpenAPI\Client\Model\FeedIndexLogsFeedDTO|null + */ + public function getFeed() + { + return $this->container['feed']; + } + + /** + * Sets feed + * + * @param \OpenAPI\Client\Model\FeedIndexLogsFeedDTO|null $feed feed + * + * @return self + */ + public function setFeed($feed) + { + if (is_null($feed)) { + throw new \InvalidArgumentException('non-nullable feed cannot be null'); + } + $this->container['feed'] = $feed; + + return $this; + } + + /** + * Gets index_log_records + * + * @return \OpenAPI\Client\Model\FeedIndexLogsRecordDTO[] + */ + public function getIndexLogRecords() + { + return $this->container['index_log_records']; + } + + /** + * Sets index_log_records + * + * @param \OpenAPI\Client\Model\FeedIndexLogsRecordDTO[] $index_log_records Список отчетов по индексации прайс-листа. + * + * @return self + */ + public function setIndexLogRecords($index_log_records) + { + if (is_null($index_log_records)) { + throw new \InvalidArgumentException('non-nullable index_log_records cannot be null'); + } + $this->container['index_log_records'] = $index_log_records; + + return $this; + } + + /** + * Gets total + * + * @return int|null + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param int|null $total Количество отчетов на всех страницах выходных данных. + * + * @return self + */ + public function setTotal($total) + { + if (is_null($total)) { + throw new \InvalidArgumentException('non-nullable total cannot be null'); + } + $this->container['total'] = $total; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedIndexLogsStatusType.php b/erp24/lib/yandex_market_api/Model/FeedIndexLogsStatusType.php new file mode 100644 index 00000000..6616a8ac --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedIndexLogsStatusType.php @@ -0,0 +1,66 @@ + + */ +class FeedParameterDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedParameterDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'deleted' => 'bool', + 'name' => 'string', + 'values' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'deleted' => null, + 'name' => null, + 'values' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'deleted' => false, + 'name' => false, + 'values' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'deleted' => 'deleted', + 'name' => 'name', + 'values' => 'values' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'deleted' => 'setDeleted', + 'name' => 'setName', + 'values' => 'setValues' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'deleted' => 'getDeleted', + 'name' => 'getName', + 'values' => 'getValues' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('deleted', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('values', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets deleted + * + * @return bool|null + */ + public function getDeleted() + { + return $this->container['deleted']; + } + + /** + * Sets deleted + * + * @param bool|null $deleted Удалить ли значение параметра. Возможное значение: * `true` — удалить значение параметра. Используется вместе с параметром `name`. + * + * @return self + */ + public function setDeleted($deleted) + { + if (is_null($deleted)) { + throw new \InvalidArgumentException('non-nullable deleted cannot be null'); + } + $this->container['deleted'] = $deleted; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название параметра. Возможное значение: - `reparseIntervalMinutes` — период скачивания прайс-листа. Маркет будет скачивать прайс-лист через количество минут, указанное в параметре `value`. Например, при `value=1440`, Маркет будет скачивать прайс-лист один раз в сутки. {% note alert %} Несмотря на установленное значение, Маркет скачает прайс-лист один раз в сутки. {% endnote %} Обязательный параметр. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets values + * + * @return int[]|null + */ + public function getValues() + { + return $this->container['values']; + } + + /** + * Sets values + * + * @param int[]|null $values Значения параметра. Используется вместе с параметром `name`. + * + * @return self + */ + public function setValues($values) + { + if (is_null($values)) { + array_push($this->openAPINullablesSetToNull, 'values'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('values', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['values'] = $values; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedPlacementDTO.php b/erp24/lib/yandex_market_api/Model/FeedPlacementDTO.php new file mode 100644 index 00000000..89b8e393 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedPlacementDTO.php @@ -0,0 +1,444 @@ + + */ +class FeedPlacementDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedPlacementDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\FeedStatusType', + 'total_offers_count' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'total_offers_count' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'total_offers_count' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'total_offers_count' => 'totalOffersCount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'total_offers_count' => 'setTotalOffersCount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'total_offers_count' => 'getTotalOffersCount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('total_offers_count', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\FeedStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\FeedStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets total_offers_count + * + * @return int|null + */ + public function getTotalOffersCount() + { + return $this->container['total_offers_count']; + } + + /** + * Sets total_offers_count + * + * @param int|null $total_offers_count Количество предложений из прайс-листа, которые размещаются на Яндекс Маркете в момент выполнения запроса. + * + * @return self + */ + public function setTotalOffersCount($total_offers_count) + { + if (is_null($total_offers_count)) { + throw new \InvalidArgumentException('non-nullable total_offers_count cannot be null'); + } + $this->container['total_offers_count'] = $total_offers_count; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedPublicationDTO.php b/erp24/lib/yandex_market_api/Model/FeedPublicationDTO.php new file mode 100644 index 00000000..0ee7c03a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedPublicationDTO.php @@ -0,0 +1,478 @@ + + */ +class FeedPublicationDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedPublicationDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\FeedStatusType', + 'full' => '\OpenAPI\Client\Model\FeedPublicationFullDTO', + 'price_and_stock_update' => '\OpenAPI\Client\Model\FeedPublicationPriceAndStockUpdateDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'full' => null, + 'price_and_stock_update' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'full' => false, + 'price_and_stock_update' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'full' => 'full', + 'price_and_stock_update' => 'priceAndStockUpdate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'full' => 'setFull', + 'price_and_stock_update' => 'setPriceAndStockUpdate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'full' => 'getFull', + 'price_and_stock_update' => 'getPriceAndStockUpdate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('full', $data ?? [], null); + $this->setIfExists('price_and_stock_update', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\FeedStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\FeedStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets full + * + * @return \OpenAPI\Client\Model\FeedPublicationFullDTO|null + */ + public function getFull() + { + return $this->container['full']; + } + + /** + * Sets full + * + * @param \OpenAPI\Client\Model\FeedPublicationFullDTO|null $full full + * + * @return self + */ + public function setFull($full) + { + if (is_null($full)) { + throw new \InvalidArgumentException('non-nullable full cannot be null'); + } + $this->container['full'] = $full; + + return $this; + } + + /** + * Gets price_and_stock_update + * + * @return \OpenAPI\Client\Model\FeedPublicationPriceAndStockUpdateDTO|null + */ + public function getPriceAndStockUpdate() + { + return $this->container['price_and_stock_update']; + } + + /** + * Sets price_and_stock_update + * + * @param \OpenAPI\Client\Model\FeedPublicationPriceAndStockUpdateDTO|null $price_and_stock_update price_and_stock_update + * + * @return self + */ + public function setPriceAndStockUpdate($price_and_stock_update) + { + if (is_null($price_and_stock_update)) { + throw new \InvalidArgumentException('non-nullable price_and_stock_update cannot be null'); + } + $this->container['price_and_stock_update'] = $price_and_stock_update; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedPublicationFullDTO.php b/erp24/lib/yandex_market_api/Model/FeedPublicationFullDTO.php new file mode 100644 index 00000000..2cff4725 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedPublicationFullDTO.php @@ -0,0 +1,444 @@ + + */ +class FeedPublicationFullDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedPublicationFullDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'file_time' => '\DateTime', + 'published_time' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'file_time' => 'date-time', + 'published_time' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'file_time' => false, + 'published_time' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'file_time' => 'fileTime', + 'published_time' => 'publishedTime' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'file_time' => 'setFileTime', + 'published_time' => 'setPublishedTime' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'file_time' => 'getFileTime', + 'published_time' => 'getPublishedTime' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('file_time', $data ?? [], null); + $this->setIfExists('published_time', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets file_time + * + * @return \DateTime|null + */ + public function getFileTime() + { + return $this->container['file_time']; + } + + /** + * Sets file_time + * + * @param \DateTime|null $file_time Дата и время, которые магазин указал в прайс-листе. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setFileTime($file_time) + { + if (is_null($file_time)) { + throw new \InvalidArgumentException('non-nullable file_time cannot be null'); + } + $this->container['file_time'] = $file_time; + + return $this; + } + + /** + * Gets published_time + * + * @return \DateTime|null + */ + public function getPublishedTime() + { + return $this->container['published_time']; + } + + /** + * Sets published_time + * + * @param \DateTime|null $published_time Дата и время публикации предложений из прайс-листа на Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setPublishedTime($published_time) + { + if (is_null($published_time)) { + throw new \InvalidArgumentException('non-nullable published_time cannot be null'); + } + $this->container['published_time'] = $published_time; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedPublicationPriceAndStockUpdateDTO.php b/erp24/lib/yandex_market_api/Model/FeedPublicationPriceAndStockUpdateDTO.php new file mode 100644 index 00000000..96a6d61a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedPublicationPriceAndStockUpdateDTO.php @@ -0,0 +1,444 @@ + + */ +class FeedPublicationPriceAndStockUpdateDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedPublicationPriceAndStockUpdateDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'file_time' => '\DateTime', + 'published_time' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'file_time' => 'date-time', + 'published_time' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'file_time' => false, + 'published_time' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'file_time' => 'fileTime', + 'published_time' => 'publishedTime' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'file_time' => 'setFileTime', + 'published_time' => 'setPublishedTime' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'file_time' => 'getFileTime', + 'published_time' => 'getPublishedTime' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('file_time', $data ?? [], null); + $this->setIfExists('published_time', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets file_time + * + * @return \DateTime|null + */ + public function getFileTime() + { + return $this->container['file_time']; + } + + /** + * Sets file_time + * + * @param \DateTime|null $file_time Дата и время, которые магазин указал в прайс-листе. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setFileTime($file_time) + { + if (is_null($file_time)) { + throw new \InvalidArgumentException('non-nullable file_time cannot be null'); + } + $this->container['file_time'] = $file_time; + + return $this; + } + + /** + * Gets published_time + * + * @return \DateTime|null + */ + public function getPublishedTime() + { + return $this->container['published_time']; + } + + /** + * Sets published_time + * + * @param \DateTime|null $published_time Дата и время публикации предложений из прайс-листа на Маркете. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setPublishedTime($published_time) + { + if (is_null($published_time)) { + throw new \InvalidArgumentException('non-nullable published_time cannot be null'); + } + $this->container['published_time'] = $published_time; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedStatusType.php b/erp24/lib/yandex_market_api/Model/FeedStatusType.php new file mode 100644 index 00000000..2693fb7e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedStatusType.php @@ -0,0 +1,66 @@ + + */ +class FeedbackAuthorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackAuthorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'region' => '\OpenAPI\Client\Model\RegionDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'region' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'region' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'region' => 'region' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'region' => 'setRegion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'region' => 'getRegion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('region', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Имя автора отзыва. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets region + * + * @return \OpenAPI\Client\Model\RegionDTO|null + */ + public function getRegion() + { + return $this->container['region']; + } + + /** + * Sets region + * + * @param \OpenAPI\Client\Model\RegionDTO|null $region region + * + * @return self + */ + public function setRegion($region) + { + if (is_null($region)) { + throw new \InvalidArgumentException('non-nullable region cannot be null'); + } + $this->container['region'] = $region; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackCommentAuthorDTO.php b/erp24/lib/yandex_market_api/Model/FeedbackCommentAuthorDTO.php new file mode 100644 index 00000000..7ca366b0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackCommentAuthorDTO.php @@ -0,0 +1,444 @@ + + */ +class FeedbackCommentAuthorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackCommentAuthorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\FeedbackCommentAuthorType', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\FeedbackCommentAuthorType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\FeedbackCommentAuthorType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Имя автора отзыва или название магазина. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackCommentAuthorType.php b/erp24/lib/yandex_market_api/Model/FeedbackCommentAuthorType.php new file mode 100644 index 00000000..4847fe7a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackCommentAuthorType.php @@ -0,0 +1,63 @@ + + */ +class FeedbackCommentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackCommentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'parent_id' => 'int', + 'body' => 'string', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime', + 'author' => '\OpenAPI\Client\Model\FeedbackCommentAuthorDTO', + 'children' => '\OpenAPI\Client\Model\FeedbackCommentDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'parent_id' => 'int64', + 'body' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time', + 'author' => null, + 'children' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'parent_id' => false, + 'body' => false, + 'created_at' => false, + 'updated_at' => false, + 'author' => false, + 'children' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'parent_id' => 'parentId', + 'body' => 'body', + 'created_at' => 'createdAt', + 'updated_at' => 'updatedAt', + 'author' => 'author', + 'children' => 'children' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'parent_id' => 'setParentId', + 'body' => 'setBody', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt', + 'author' => 'setAuthor', + 'children' => 'setChildren' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'parent_id' => 'getParentId', + 'body' => 'getBody', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt', + 'author' => 'getAuthor', + 'children' => 'getChildren' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('parent_id', $data ?? [], null); + $this->setIfExists('body', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + $this->setIfExists('author', $data ?? [], null); + $this->setIfExists('children', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор ответа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets parent_id + * + * @return int|null + */ + public function getParentId() + { + return $this->container['parent_id']; + } + + /** + * Sets parent_id + * + * @param int|null $parent_id Идентификатор родительского ответа. + * + * @return self + */ + public function setParentId($parent_id) + { + if (is_null($parent_id)) { + throw new \InvalidArgumentException('non-nullable parent_id cannot be null'); + } + $this->container['parent_id'] = $parent_id; + + return $this; + } + + /** + * Gets body + * + * @return string|null + */ + public function getBody() + { + return $this->container['body']; + } + + /** + * Sets body + * + * @param string|null $body Текст ответа. + * + * @return self + */ + public function setBody($body) + { + if (is_null($body)) { + throw new \InvalidArgumentException('non-nullable body cannot be null'); + } + $this->container['body'] = $body; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at Дата и время создания ответа. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:00:00+03:00`. + * + * @return self + */ + public function setCreatedAt($created_at) + { + if (is_null($created_at)) { + throw new \InvalidArgumentException('non-nullable created_at cannot be null'); + } + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at Дата и время изменения ответа. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:00:00+03:00`. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + + /** + * Gets author + * + * @return \OpenAPI\Client\Model\FeedbackCommentAuthorDTO|null + */ + public function getAuthor() + { + return $this->container['author']; + } + + /** + * Sets author + * + * @param \OpenAPI\Client\Model\FeedbackCommentAuthorDTO|null $author author + * + * @return self + */ + public function setAuthor($author) + { + if (is_null($author)) { + throw new \InvalidArgumentException('non-nullable author cannot be null'); + } + $this->container['author'] = $author; + + return $this; + } + + /** + * Gets children + * + * @return \OpenAPI\Client\Model\FeedbackCommentDTO[]|null + */ + public function getChildren() + { + return $this->container['children']; + } + + /** + * Sets children + * + * @param \OpenAPI\Client\Model\FeedbackCommentDTO[]|null $children Дочерние ответы. + * + * @return self + */ + public function setChildren($children) + { + if (is_null($children)) { + array_push($this->openAPINullablesSetToNull, 'children'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('children', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['children'] = $children; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackDTO.php b/erp24/lib/yandex_market_api/Model/FeedbackDTO.php new file mode 100644 index 00000000..8fc6b600 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackDTO.php @@ -0,0 +1,855 @@ + + */ +class FeedbackDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'created_at' => '\DateTime', + 'text' => 'string', + 'state' => '\OpenAPI\Client\Model\FeedbackStateType', + 'author' => '\OpenAPI\Client\Model\FeedbackAuthorDTO', + 'pro' => 'string', + 'contra' => 'string', + 'comments' => '\OpenAPI\Client\Model\FeedbackCommentDTO[]', + 'shop' => '\OpenAPI\Client\Model\FeedbackShopDTO', + 'resolved' => 'bool', + 'verified' => 'bool', + 'recommend' => 'bool', + 'grades' => '\OpenAPI\Client\Model\FeedbackGradesDTO', + 'order' => '\OpenAPI\Client\Model\FeedbackOrderDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'created_at' => 'date-time', + 'text' => null, + 'state' => null, + 'author' => null, + 'pro' => null, + 'contra' => null, + 'comments' => null, + 'shop' => null, + 'resolved' => null, + 'verified' => null, + 'recommend' => null, + 'grades' => null, + 'order' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'created_at' => false, + 'text' => false, + 'state' => false, + 'author' => false, + 'pro' => false, + 'contra' => false, + 'comments' => false, + 'shop' => false, + 'resolved' => false, + 'verified' => false, + 'recommend' => false, + 'grades' => false, + 'order' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'created_at' => 'createdAt', + 'text' => 'text', + 'state' => 'state', + 'author' => 'author', + 'pro' => 'pro', + 'contra' => 'contra', + 'comments' => 'comments', + 'shop' => 'shop', + 'resolved' => 'resolved', + 'verified' => 'verified', + 'recommend' => 'recommend', + 'grades' => 'grades', + 'order' => 'order' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'created_at' => 'setCreatedAt', + 'text' => 'setText', + 'state' => 'setState', + 'author' => 'setAuthor', + 'pro' => 'setPro', + 'contra' => 'setContra', + 'comments' => 'setComments', + 'shop' => 'setShop', + 'resolved' => 'setResolved', + 'verified' => 'setVerified', + 'recommend' => 'setRecommend', + 'grades' => 'setGrades', + 'order' => 'setOrder' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'created_at' => 'getCreatedAt', + 'text' => 'getText', + 'state' => 'getState', + 'author' => 'getAuthor', + 'pro' => 'getPro', + 'contra' => 'getContra', + 'comments' => 'getComments', + 'shop' => 'getShop', + 'resolved' => 'getResolved', + 'verified' => 'getVerified', + 'recommend' => 'getRecommend', + 'grades' => 'getGrades', + 'order' => 'getOrder' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('text', $data ?? [], null); + $this->setIfExists('state', $data ?? [], null); + $this->setIfExists('author', $data ?? [], null); + $this->setIfExists('pro', $data ?? [], null); + $this->setIfExists('contra', $data ?? [], null); + $this->setIfExists('comments', $data ?? [], null); + $this->setIfExists('shop', $data ?? [], null); + $this->setIfExists('resolved', $data ?? [], null); + $this->setIfExists('verified', $data ?? [], null); + $this->setIfExists('recommend', $data ?? [], null); + $this->setIfExists('grades', $data ?? [], null); + $this->setIfExists('order', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['comments'] === null) { + $invalidProperties[] = "'comments' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор отзыва. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at Дата и время создания отзыва. Формат даты: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:00:00+03:00`. + * + * @return self + */ + public function setCreatedAt($created_at) + { + if (is_null($created_at)) { + throw new \InvalidArgumentException('non-nullable created_at cannot be null'); + } + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets text + * + * @return string|null + */ + public function getText() + { + return $this->container['text']; + } + + /** + * Sets text + * + * @param string|null $text Комментарий автора отзыва. + * + * @return self + */ + public function setText($text) + { + if (is_null($text)) { + throw new \InvalidArgumentException('non-nullable text cannot be null'); + } + $this->container['text'] = $text; + + return $this; + } + + /** + * Gets state + * + * @return \OpenAPI\Client\Model\FeedbackStateType|null + */ + public function getState() + { + return $this->container['state']; + } + + /** + * Sets state + * + * @param \OpenAPI\Client\Model\FeedbackStateType|null $state state + * + * @return self + */ + public function setState($state) + { + if (is_null($state)) { + throw new \InvalidArgumentException('non-nullable state cannot be null'); + } + $this->container['state'] = $state; + + return $this; + } + + /** + * Gets author + * + * @return \OpenAPI\Client\Model\FeedbackAuthorDTO|null + */ + public function getAuthor() + { + return $this->container['author']; + } + + /** + * Sets author + * + * @param \OpenAPI\Client\Model\FeedbackAuthorDTO|null $author author + * + * @return self + */ + public function setAuthor($author) + { + if (is_null($author)) { + throw new \InvalidArgumentException('non-nullable author cannot be null'); + } + $this->container['author'] = $author; + + return $this; + } + + /** + * Gets pro + * + * @return string|null + */ + public function getPro() + { + return $this->container['pro']; + } + + /** + * Sets pro + * + * @param string|null $pro Достоинства магазина, описанные в отзыве. + * + * @return self + */ + public function setPro($pro) + { + if (is_null($pro)) { + throw new \InvalidArgumentException('non-nullable pro cannot be null'); + } + $this->container['pro'] = $pro; + + return $this; + } + + /** + * Gets contra + * + * @return string|null + */ + public function getContra() + { + return $this->container['contra']; + } + + /** + * Sets contra + * + * @param string|null $contra Недостатки магазина, описанные в отзыве. + * + * @return self + */ + public function setContra($contra) + { + if (is_null($contra)) { + throw new \InvalidArgumentException('non-nullable contra cannot be null'); + } + $this->container['contra'] = $contra; + + return $this; + } + + /** + * Gets comments + * + * @return \OpenAPI\Client\Model\FeedbackCommentDTO[] + */ + public function getComments() + { + return $this->container['comments']; + } + + /** + * Sets comments + * + * @param \OpenAPI\Client\Model\FeedbackCommentDTO[] $comments Переписка автора отзыва с магазином. + * + * @return self + */ + public function setComments($comments) + { + if (is_null($comments)) { + throw new \InvalidArgumentException('non-nullable comments cannot be null'); + } + $this->container['comments'] = $comments; + + return $this; + } + + /** + * Gets shop + * + * @return \OpenAPI\Client\Model\FeedbackShopDTO|null + */ + public function getShop() + { + return $this->container['shop']; + } + + /** + * Sets shop + * + * @param \OpenAPI\Client\Model\FeedbackShopDTO|null $shop shop + * + * @return self + */ + public function setShop($shop) + { + if (is_null($shop)) { + throw new \InvalidArgumentException('non-nullable shop cannot be null'); + } + $this->container['shop'] = $shop; + + return $this; + } + + /** + * Gets resolved + * + * @return bool|null + */ + public function getResolved() + { + return $this->container['resolved']; + } + + /** + * Sets resolved + * + * @param bool|null $resolved Решена ли проблема автора отзыва: * `true` — да. * `false` — нет. Если проблема решена, около отзыва на странице магазина появляется соответствующая надпись. + * + * @return self + */ + public function setResolved($resolved) + { + if (is_null($resolved)) { + throw new \InvalidArgumentException('non-nullable resolved cannot be null'); + } + $this->container['resolved'] = $resolved; + + return $this; + } + + /** + * Gets verified + * + * @return bool|null + */ + public function getVerified() + { + return $this->container['verified']; + } + + /** + * Sets verified + * + * @param bool|null $verified {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Является ли отзыв рекомендованным: * `true` — да. * `false` — нет. + * + * @return self + */ + public function setVerified($verified) + { + if (is_null($verified)) { + throw new \InvalidArgumentException('non-nullable verified cannot be null'); + } + $this->container['verified'] = $verified; + + return $this; + } + + /** + * Gets recommend + * + * @return bool|null + */ + public function getRecommend() + { + return $this->container['recommend']; + } + + /** + * Sets recommend + * + * @param bool|null $recommend Купил бы автор отзыва в магазине снова: * `true` — да. * `false` — нет. + * + * @return self + */ + public function setRecommend($recommend) + { + if (is_null($recommend)) { + throw new \InvalidArgumentException('non-nullable recommend cannot be null'); + } + $this->container['recommend'] = $recommend; + + return $this; + } + + /** + * Gets grades + * + * @return \OpenAPI\Client\Model\FeedbackGradesDTO|null + */ + public function getGrades() + { + return $this->container['grades']; + } + + /** + * Sets grades + * + * @param \OpenAPI\Client\Model\FeedbackGradesDTO|null $grades grades + * + * @return self + */ + public function setGrades($grades) + { + if (is_null($grades)) { + throw new \InvalidArgumentException('non-nullable grades cannot be null'); + } + $this->container['grades'] = $grades; + + return $this; + } + + /** + * Gets order + * + * @return \OpenAPI\Client\Model\FeedbackOrderDTO|null + */ + public function getOrder() + { + return $this->container['order']; + } + + /** + * Sets order + * + * @param \OpenAPI\Client\Model\FeedbackOrderDTO|null $order order + * + * @return self + */ + public function setOrder($order) + { + if (is_null($order)) { + throw new \InvalidArgumentException('non-nullable order cannot be null'); + } + $this->container['order'] = $order; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackDeliveryType.php b/erp24/lib/yandex_market_api/Model/FeedbackDeliveryType.php new file mode 100644 index 00000000..559f0de8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackDeliveryType.php @@ -0,0 +1,66 @@ + + */ +class FeedbackFactorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackFactorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'title' => 'string', + 'description' => 'string', + 'value' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'title' => null, + 'description' => null, + 'value' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'title' => false, + 'description' => false, + 'value' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'title' => 'title', + 'description' => 'description', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'title' => 'setTitle', + 'description' => 'setDescription', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'title' => 'getTitle', + 'description' => 'getDescription', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('title', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('value', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор параметра. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets title + * + * @return string|null + */ + public function getTitle() + { + return $this->container['title']; + } + + /** + * Sets title + * + * @param string|null $title Название параметра. Например, `Скорость обработки заказа`. + * + * @return self + */ + public function setTitle($title) + { + if (is_null($title)) { + throw new \InvalidArgumentException('non-nullable title cannot be null'); + } + $this->container['title'] = $title; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Описание параметра. Например, `Как быстро с вами связались для подтверждения заказа?`. + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets value + * + * @return int|null + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param int|null $value Оценка по параметру, указанная в отзыве: от `1` (низшая оценка) до `5` (высшая оценка). + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackGradesDTO.php b/erp24/lib/yandex_market_api/Model/FeedbackGradesDTO.php new file mode 100644 index 00000000..59bb5f67 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackGradesDTO.php @@ -0,0 +1,515 @@ + + */ +class FeedbackGradesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackGradesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'average' => 'float', + 'agree_count' => 'int', + 'reject_count' => 'int', + 'factors' => '\OpenAPI\Client\Model\FeedbackFactorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'average' => null, + 'agree_count' => 'int64', + 'reject_count' => 'int64', + 'factors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'average' => false, + 'agree_count' => false, + 'reject_count' => false, + 'factors' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'average' => 'average', + 'agree_count' => 'agreeCount', + 'reject_count' => 'rejectCount', + 'factors' => 'factors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'average' => 'setAverage', + 'agree_count' => 'setAgreeCount', + 'reject_count' => 'setRejectCount', + 'factors' => 'setFactors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'average' => 'getAverage', + 'agree_count' => 'getAgreeCount', + 'reject_count' => 'getRejectCount', + 'factors' => 'getFactors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('average', $data ?? [], null); + $this->setIfExists('agree_count', $data ?? [], null); + $this->setIfExists('reject_count', $data ?? [], null); + $this->setIfExists('factors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['factors'] === null) { + $invalidProperties[] = "'factors' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets average + * + * @return float|null + */ + public function getAverage() + { + return $this->container['average']; + } + + /** + * Sets average + * + * @param float|null $average Общая оценка, указанная в отзыве: от `1` («Ужасный магазин») до `5` («Отличный магазин»). + * + * @return self + */ + public function setAverage($average) + { + if (is_null($average)) { + throw new \InvalidArgumentException('non-nullable average cannot be null'); + } + $this->container['average'] = $average; + + return $this; + } + + /** + * Gets agree_count + * + * @return int|null + */ + public function getAgreeCount() + { + return $this->container['agree_count']; + } + + /** + * Sets agree_count + * + * @param int|null $agree_count Количество пользователей, считающих отзыв полезным. + * + * @return self + */ + public function setAgreeCount($agree_count) + { + if (is_null($agree_count)) { + throw new \InvalidArgumentException('non-nullable agree_count cannot be null'); + } + $this->container['agree_count'] = $agree_count; + + return $this; + } + + /** + * Gets reject_count + * + * @return int|null + */ + public function getRejectCount() + { + return $this->container['reject_count']; + } + + /** + * Sets reject_count + * + * @param int|null $reject_count Количество пользователей, считающих отзыв бесполезным. + * + * @return self + */ + public function setRejectCount($reject_count) + { + if (is_null($reject_count)) { + throw new \InvalidArgumentException('non-nullable reject_count cannot be null'); + } + $this->container['reject_count'] = $reject_count; + + return $this; + } + + /** + * Gets factors + * + * @return \OpenAPI\Client\Model\FeedbackFactorDTO[] + */ + public function getFactors() + { + return $this->container['factors']; + } + + /** + * Sets factors + * + * @param \OpenAPI\Client\Model\FeedbackFactorDTO[] $factors Информация об оценках по параметрам, указанных в отзыве. При создании отзыва автору предлагается поставить оценки магазину по нескольким параметрам: например, за скорость обработки заказа или удобство самовывоза. Набор параметров зависит от того, какой способ покупки (параметр `delivery`) указал автор. + * + * @return self + */ + public function setFactors($factors) + { + if (is_null($factors)) { + throw new \InvalidArgumentException('non-nullable factors cannot be null'); + } + $this->container['factors'] = $factors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackListDTO.php b/erp24/lib/yandex_market_api/Model/FeedbackListDTO.php new file mode 100644 index 00000000..de14db06 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackListDTO.php @@ -0,0 +1,447 @@ + + */ +class FeedbackListDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackListDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'feedback_list' => '\OpenAPI\Client\Model\FeedbackDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'feedback_list' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'feedback_list' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'feedback_list' => 'feedbackList' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'feedback_list' => 'setFeedbackList' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'feedback_list' => 'getFeedbackList' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('feedback_list', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['feedback_list'] === null) { + $invalidProperties[] = "'feedback_list' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets feedback_list + * + * @return \OpenAPI\Client\Model\FeedbackDTO[] + */ + public function getFeedbackList() + { + return $this->container['feedback_list']; + } + + /** + * Sets feedback_list + * + * @param \OpenAPI\Client\Model\FeedbackDTO[] $feedback_list Список отзывов. Содержит не более 20 отзывов. + * + * @return self + */ + public function setFeedbackList($feedback_list) + { + if (is_null($feedback_list)) { + throw new \InvalidArgumentException('non-nullable feedback_list cannot be null'); + } + $this->container['feedback_list'] = $feedback_list; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackOrderDTO.php b/erp24/lib/yandex_market_api/Model/FeedbackOrderDTO.php new file mode 100644 index 00000000..b05600b3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackOrderDTO.php @@ -0,0 +1,444 @@ + + */ +class FeedbackOrderDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackOrderDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'shop_order_id' => 'string', + 'delivery' => '\OpenAPI\Client\Model\FeedbackDeliveryType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'shop_order_id' => null, + 'delivery' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'shop_order_id' => false, + 'delivery' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'shop_order_id' => 'shopOrderId', + 'delivery' => 'delivery' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'shop_order_id' => 'setShopOrderId', + 'delivery' => 'setDelivery' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'shop_order_id' => 'getShopOrderId', + 'delivery' => 'getDelivery' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('shop_order_id', $data ?? [], null); + $this->setIfExists('delivery', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets shop_order_id + * + * @return string|null + */ + public function getShopOrderId() + { + return $this->container['shop_order_id']; + } + + /** + * Sets shop_order_id + * + * @param string|null $shop_order_id Номер заказа, указанный в отзыве. + * + * @return self + */ + public function setShopOrderId($shop_order_id) + { + if (is_null($shop_order_id)) { + throw new \InvalidArgumentException('non-nullable shop_order_id cannot be null'); + } + $this->container['shop_order_id'] = $shop_order_id; + + return $this; + } + + /** + * Gets delivery + * + * @return \OpenAPI\Client\Model\FeedbackDeliveryType|null + */ + public function getDelivery() + { + return $this->container['delivery']; + } + + /** + * Sets delivery + * + * @param \OpenAPI\Client\Model\FeedbackDeliveryType|null $delivery delivery + * + * @return self + */ + public function setDelivery($delivery) + { + if (is_null($delivery)) { + throw new \InvalidArgumentException('non-nullable delivery cannot be null'); + } + $this->container['delivery'] = $delivery; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackReactionStatusType.php b/erp24/lib/yandex_market_api/Model/FeedbackReactionStatusType.php new file mode 100644 index 00000000..d91befa9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackReactionStatusType.php @@ -0,0 +1,63 @@ + + */ +class FeedbackShopDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FeedbackShopDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название магазина. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FeedbackStateType.php b/erp24/lib/yandex_market_api/Model/FeedbackStateType.php new file mode 100644 index 00000000..92dc44fd --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FeedbackStateType.php @@ -0,0 +1,66 @@ + + */ +class FlippingPagerDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FlippingPagerDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'total' => 'int', + 'from' => 'int', + 'to' => 'int', + 'current_page' => 'int', + 'pages_count' => 'int', + 'page_size' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'total' => 'int32', + 'from' => 'int32', + 'to' => 'int32', + 'current_page' => 'int32', + 'pages_count' => 'int32', + 'page_size' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'total' => false, + 'from' => false, + 'to' => false, + 'current_page' => false, + 'pages_count' => false, + 'page_size' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'total' => 'total', + 'from' => 'from', + 'to' => 'to', + 'current_page' => 'currentPage', + 'pages_count' => 'pagesCount', + 'page_size' => 'pageSize' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'total' => 'setTotal', + 'from' => 'setFrom', + 'to' => 'setTo', + 'current_page' => 'setCurrentPage', + 'pages_count' => 'setPagesCount', + 'page_size' => 'setPageSize' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'total' => 'getTotal', + 'from' => 'getFrom', + 'to' => 'getTo', + 'current_page' => 'getCurrentPage', + 'pages_count' => 'getPagesCount', + 'page_size' => 'getPageSize' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('from', $data ?? [], null); + $this->setIfExists('to', $data ?? [], null); + $this->setIfExists('current_page', $data ?? [], null); + $this->setIfExists('pages_count', $data ?? [], null); + $this->setIfExists('page_size', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets total + * + * @return int|null + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param int|null $total Сколько всего найдено элементов. + * + * @return self + */ + public function setTotal($total) + { + if (is_null($total)) { + throw new \InvalidArgumentException('non-nullable total cannot be null'); + } + $this->container['total'] = $total; + + return $this; + } + + /** + * Gets from + * + * @return int|null + */ + public function getFrom() + { + return $this->container['from']; + } + + /** + * Sets from + * + * @param int|null $from Начальный номер найденного элемента на странице. + * + * @return self + */ + public function setFrom($from) + { + if (is_null($from)) { + throw new \InvalidArgumentException('non-nullable from cannot be null'); + } + $this->container['from'] = $from; + + return $this; + } + + /** + * Gets to + * + * @return int|null + */ + public function getTo() + { + return $this->container['to']; + } + + /** + * Sets to + * + * @param int|null $to Конечный номер найденного элемента на странице. + * + * @return self + */ + public function setTo($to) + { + if (is_null($to)) { + throw new \InvalidArgumentException('non-nullable to cannot be null'); + } + $this->container['to'] = $to; + + return $this; + } + + /** + * Gets current_page + * + * @return int|null + */ + public function getCurrentPage() + { + return $this->container['current_page']; + } + + /** + * Sets current_page + * + * @param int|null $current_page Текущая страница. + * + * @return self + */ + public function setCurrentPage($current_page) + { + if (is_null($current_page)) { + throw new \InvalidArgumentException('non-nullable current_page cannot be null'); + } + $this->container['current_page'] = $current_page; + + return $this; + } + + /** + * Gets pages_count + * + * @return int|null + */ + public function getPagesCount() + { + return $this->container['pages_count']; + } + + /** + * Sets pages_count + * + * @param int|null $pages_count Общее количество страниц. + * + * @return self + */ + public function setPagesCount($pages_count) + { + if (is_null($pages_count)) { + throw new \InvalidArgumentException('non-nullable pages_count cannot be null'); + } + $this->container['pages_count'] = $pages_count; + + return $this; + } + + /** + * Gets page_size + * + * @return int|null + */ + public function getPageSize() + { + return $this->container['page_size']; + } + + /** + * Sets page_size + * + * @param int|null $page_size Размер страницы. + * + * @return self + */ + public function setPageSize($page_size) + { + if (is_null($page_size)) { + throw new \InvalidArgumentException('non-nullable page_size cannot be null'); + } + $this->container['page_size'] = $page_size; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ForwardScrollingPagerDTO.php b/erp24/lib/yandex_market_api/Model/ForwardScrollingPagerDTO.php new file mode 100644 index 00000000..520230c5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ForwardScrollingPagerDTO.php @@ -0,0 +1,410 @@ + + */ +class ForwardScrollingPagerDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ForwardScrollingPagerDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'next_page_token' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'next_page_token' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'next_page_token' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'next_page_token' => 'nextPageToken' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'next_page_token' => 'setNextPageToken' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'next_page_token' => 'getNextPageToken' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('next_page_token', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets next_page_token + * + * @return string|null + */ + public function getNextPageToken() + { + return $this->container['next_page_token']; + } + + /** + * Sets next_page_token + * + * @param string|null $next_page_token Идентификатор следующей страницы результатов. + * + * @return self + */ + public function setNextPageToken($next_page_token) + { + if (is_null($next_page_token)) { + throw new \InvalidArgumentException('non-nullable next_page_token cannot be null'); + } + $this->container['next_page_token'] = $next_page_token; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FulfillmentWarehouseDTO.php b/erp24/lib/yandex_market_api/Model/FulfillmentWarehouseDTO.php new file mode 100644 index 00000000..ea56098c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FulfillmentWarehouseDTO.php @@ -0,0 +1,484 @@ + + */ +class FulfillmentWarehouseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FulfillmentWarehouseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'address' => '\OpenAPI\Client\Model\WarehouseAddressDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'address' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'address' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'address' => 'address' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'address' => 'setAddress' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'address' => 'getAddress' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('address', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор склада. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название склада. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets address + * + * @return \OpenAPI\Client\Model\WarehouseAddressDTO|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \OpenAPI\Client\Model\WarehouseAddressDTO|null $address address + * + * @return self + */ + public function setAddress($address) + { + if (is_null($address)) { + throw new \InvalidArgumentException('non-nullable address cannot be null'); + } + $this->container['address'] = $address; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FulfillmentWarehousesDTO.php b/erp24/lib/yandex_market_api/Model/FulfillmentWarehousesDTO.php new file mode 100644 index 00000000..0c5c1540 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FulfillmentWarehousesDTO.php @@ -0,0 +1,413 @@ + + */ +class FulfillmentWarehousesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FulfillmentWarehousesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'warehouses' => '\OpenAPI\Client\Model\FulfillmentWarehouseDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'warehouses' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'warehouses' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'warehouses' => 'warehouses' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'warehouses' => 'setWarehouses' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'warehouses' => 'getWarehouses' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('warehouses', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['warehouses'] === null) { + $invalidProperties[] = "'warehouses' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets warehouses + * + * @return \OpenAPI\Client\Model\FulfillmentWarehouseDTO[] + */ + public function getWarehouses() + { + return $this->container['warehouses']; + } + + /** + * Sets warehouses + * + * @param \OpenAPI\Client\Model\FulfillmentWarehouseDTO[] $warehouses Список складов Маркета (FBY). + * + * @return self + */ + public function setWarehouses($warehouses) + { + if (is_null($warehouses)) { + throw new \InvalidArgumentException('non-nullable warehouses cannot be null'); + } + $this->container['warehouses'] = $warehouses; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FullOutletDTO.php b/erp24/lib/yandex_market_api/Model/FullOutletDTO.php new file mode 100644 index 00000000..da9f26f0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FullOutletDTO.php @@ -0,0 +1,988 @@ + + */ +class FullOutletDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FullOutletDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'type' => '\OpenAPI\Client\Model\OutletType', + 'coords' => 'string', + 'is_main' => 'bool', + 'shop_outlet_code' => 'string', + 'visibility' => '\OpenAPI\Client\Model\OutletVisibilityType', + 'address' => '\OpenAPI\Client\Model\OutletAddressDTO', + 'phones' => 'string[]', + 'working_schedule' => '\OpenAPI\Client\Model\OutletWorkingScheduleDTO', + 'delivery_rules' => '\OpenAPI\Client\Model\OutletDeliveryRuleDTO[]', + 'storage_period' => 'int', + 'id' => 'int', + 'status' => '\OpenAPI\Client\Model\OutletStatusType', + 'region' => '\OpenAPI\Client\Model\RegionDTO', + 'shop_outlet_id' => 'string', + 'working_time' => 'string', + 'moderation_reason' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'type' => null, + 'coords' => null, + 'is_main' => null, + 'shop_outlet_code' => null, + 'visibility' => null, + 'address' => null, + 'phones' => null, + 'working_schedule' => null, + 'delivery_rules' => null, + 'storage_period' => 'int64', + 'id' => 'int64', + 'status' => null, + 'region' => null, + 'shop_outlet_id' => null, + 'working_time' => null, + 'moderation_reason' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'type' => false, + 'coords' => false, + 'is_main' => false, + 'shop_outlet_code' => false, + 'visibility' => false, + 'address' => false, + 'phones' => false, + 'working_schedule' => false, + 'delivery_rules' => true, + 'storage_period' => false, + 'id' => false, + 'status' => false, + 'region' => false, + 'shop_outlet_id' => false, + 'working_time' => false, + 'moderation_reason' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'type' => 'type', + 'coords' => 'coords', + 'is_main' => 'isMain', + 'shop_outlet_code' => 'shopOutletCode', + 'visibility' => 'visibility', + 'address' => 'address', + 'phones' => 'phones', + 'working_schedule' => 'workingSchedule', + 'delivery_rules' => 'deliveryRules', + 'storage_period' => 'storagePeriod', + 'id' => 'id', + 'status' => 'status', + 'region' => 'region', + 'shop_outlet_id' => 'shopOutletId', + 'working_time' => 'workingTime', + 'moderation_reason' => 'moderationReason' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'type' => 'setType', + 'coords' => 'setCoords', + 'is_main' => 'setIsMain', + 'shop_outlet_code' => 'setShopOutletCode', + 'visibility' => 'setVisibility', + 'address' => 'setAddress', + 'phones' => 'setPhones', + 'working_schedule' => 'setWorkingSchedule', + 'delivery_rules' => 'setDeliveryRules', + 'storage_period' => 'setStoragePeriod', + 'id' => 'setId', + 'status' => 'setStatus', + 'region' => 'setRegion', + 'shop_outlet_id' => 'setShopOutletId', + 'working_time' => 'setWorkingTime', + 'moderation_reason' => 'setModerationReason' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'type' => 'getType', + 'coords' => 'getCoords', + 'is_main' => 'getIsMain', + 'shop_outlet_code' => 'getShopOutletCode', + 'visibility' => 'getVisibility', + 'address' => 'getAddress', + 'phones' => 'getPhones', + 'working_schedule' => 'getWorkingSchedule', + 'delivery_rules' => 'getDeliveryRules', + 'storage_period' => 'getStoragePeriod', + 'id' => 'getId', + 'status' => 'getStatus', + 'region' => 'getRegion', + 'shop_outlet_id' => 'getShopOutletId', + 'working_time' => 'getWorkingTime', + 'moderation_reason' => 'getModerationReason' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('coords', $data ?? [], null); + $this->setIfExists('is_main', $data ?? [], null); + $this->setIfExists('shop_outlet_code', $data ?? [], null); + $this->setIfExists('visibility', $data ?? [], null); + $this->setIfExists('address', $data ?? [], null); + $this->setIfExists('phones', $data ?? [], null); + $this->setIfExists('working_schedule', $data ?? [], null); + $this->setIfExists('delivery_rules', $data ?? [], null); + $this->setIfExists('storage_period', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('region', $data ?? [], null); + $this->setIfExists('shop_outlet_id', $data ?? [], null); + $this->setIfExists('working_time', $data ?? [], null); + $this->setIfExists('moderation_reason', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['address'] === null) { + $invalidProperties[] = "'address' can't be null"; + } + if ($this->container['phones'] === null) { + $invalidProperties[] = "'phones' can't be null"; + } + if ((count($this->container['phones']) < 1)) { + $invalidProperties[] = "invalid value for 'phones', number of items must be greater than or equal to 1."; + } + + if ($this->container['working_schedule'] === null) { + $invalidProperties[] = "'working_schedule' can't be null"; + } + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название точки продаж. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OutletType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OutletType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets coords + * + * @return string|null + */ + public function getCoords() + { + return $this->container['coords']; + } + + /** + * Sets coords + * + * @param string|null $coords Координаты точки продаж. Формат: долгота, широта. Разделители: запятая и / или пробел. Например, `20.4522144, 54.7104264`. Если параметр не передан, координаты будут определены по значениям параметров, вложенных в `address`. + * + * @return self + */ + public function setCoords($coords) + { + if (is_null($coords)) { + throw new \InvalidArgumentException('non-nullable coords cannot be null'); + } + $this->container['coords'] = $coords; + + return $this; + } + + /** + * Gets is_main + * + * @return bool|null + */ + public function getIsMain() + { + return $this->container['is_main']; + } + + /** + * Sets is_main + * + * @param bool|null $is_main Признак основной точки продаж. Возможные значения: * `false` — неосновная точка продаж. * `true` — основная точка продаж. + * + * @return self + */ + public function setIsMain($is_main) + { + if (is_null($is_main)) { + throw new \InvalidArgumentException('non-nullable is_main cannot be null'); + } + $this->container['is_main'] = $is_main; + + return $this; + } + + /** + * Gets shop_outlet_code + * + * @return string|null + */ + public function getShopOutletCode() + { + return $this->container['shop_outlet_code']; + } + + /** + * Sets shop_outlet_code + * + * @param string|null $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. + * + * @return self + */ + public function setShopOutletCode($shop_outlet_code) + { + if (is_null($shop_outlet_code)) { + throw new \InvalidArgumentException('non-nullable shop_outlet_code cannot be null'); + } + $this->container['shop_outlet_code'] = $shop_outlet_code; + + return $this; + } + + /** + * Gets visibility + * + * @return \OpenAPI\Client\Model\OutletVisibilityType|null + */ + public function getVisibility() + { + return $this->container['visibility']; + } + + /** + * Sets visibility + * + * @param \OpenAPI\Client\Model\OutletVisibilityType|null $visibility visibility + * + * @return self + */ + public function setVisibility($visibility) + { + if (is_null($visibility)) { + throw new \InvalidArgumentException('non-nullable visibility cannot be null'); + } + $this->container['visibility'] = $visibility; + + return $this; + } + + /** + * Gets address + * + * @return \OpenAPI\Client\Model\OutletAddressDTO + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \OpenAPI\Client\Model\OutletAddressDTO $address address + * + * @return self + */ + public function setAddress($address) + { + if (is_null($address)) { + throw new \InvalidArgumentException('non-nullable address cannot be null'); + } + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets phones + * + * @return string[] + */ + public function getPhones() + { + return $this->container['phones']; + } + + /** + * Sets phones + * + * @param string[] $phones Номера телефонов точки продаж. Передавайте в формате: `+7 (999) 999-99-99`. + * + * @return self + */ + public function setPhones($phones) + { + if (is_null($phones)) { + throw new \InvalidArgumentException('non-nullable phones cannot be null'); + } + + + if ((count($phones) < 1)) { + throw new \InvalidArgumentException('invalid length for $phones when calling FullOutletDTO., number of items must be greater than or equal to 1.'); + } + $this->container['phones'] = $phones; + + return $this; + } + + /** + * Gets working_schedule + * + * @return \OpenAPI\Client\Model\OutletWorkingScheduleDTO + */ + public function getWorkingSchedule() + { + return $this->container['working_schedule']; + } + + /** + * Sets working_schedule + * + * @param \OpenAPI\Client\Model\OutletWorkingScheduleDTO $working_schedule working_schedule + * + * @return self + */ + public function setWorkingSchedule($working_schedule) + { + if (is_null($working_schedule)) { + throw new \InvalidArgumentException('non-nullable working_schedule cannot be null'); + } + $this->container['working_schedule'] = $working_schedule; + + return $this; + } + + /** + * Gets delivery_rules + * + * @return \OpenAPI\Client\Model\OutletDeliveryRuleDTO[]|null + */ + public function getDeliveryRules() + { + return $this->container['delivery_rules']; + } + + /** + * Sets delivery_rules + * + * @param \OpenAPI\Client\Model\OutletDeliveryRuleDTO[]|null $delivery_rules Информация об условиях доставки для данной точки продаж. Обязательный параметр, если параметр `type=DEPOT` или `type=MIXED`. + * + * @return self + */ + public function setDeliveryRules($delivery_rules) + { + if (is_null($delivery_rules)) { + array_push($this->openAPINullablesSetToNull, 'delivery_rules'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('delivery_rules', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['delivery_rules'] = $delivery_rules; + + return $this; + } + + /** + * Gets storage_period + * + * @return int|null + */ + public function getStoragePeriod() + { + return $this->container['storage_period']; + } + + /** + * Sets storage_period + * + * @param int|null $storage_period Срок хранения заказа в собственном пункте выдачи заказов. Считается в днях. + * + * @return self + */ + public function setStoragePeriod($storage_period) + { + if (is_null($storage_period)) { + throw new \InvalidArgumentException('non-nullable storage_period cannot be null'); + } + $this->container['storage_period'] = $storage_period; + + return $this; + } + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор точки продаж, присвоенный Маркетом. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OutletStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OutletStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets region + * + * @return \OpenAPI\Client\Model\RegionDTO|null + */ + public function getRegion() + { + return $this->container['region']; + } + + /** + * Sets region + * + * @param \OpenAPI\Client\Model\RegionDTO|null $region region + * + * @return self + */ + public function setRegion($region) + { + if (is_null($region)) { + throw new \InvalidArgumentException('non-nullable region cannot be null'); + } + $this->container['region'] = $region; + + return $this; + } + + /** + * Gets shop_outlet_id + * + * @return string|null + */ + public function getShopOutletId() + { + return $this->container['shop_outlet_id']; + } + + /** + * Sets shop_outlet_id + * + * @param string|null $shop_outlet_id Идентификатор точки продаж, заданный магазином. + * + * @return self + */ + public function setShopOutletId($shop_outlet_id) + { + if (is_null($shop_outlet_id)) { + throw new \InvalidArgumentException('non-nullable shop_outlet_id cannot be null'); + } + $this->container['shop_outlet_id'] = $shop_outlet_id; + + return $this; + } + + /** + * Gets working_time + * + * @return string|null + */ + public function getWorkingTime() + { + return $this->container['working_time']; + } + + /** + * Sets working_time + * + * @param string|null $working_time Рабочее время. + * + * @return self + */ + public function setWorkingTime($working_time) + { + if (is_null($working_time)) { + throw new \InvalidArgumentException('non-nullable working_time cannot be null'); + } + $this->container['working_time'] = $working_time; + + return $this; + } + + /** + * Gets moderation_reason + * + * @return string|null + */ + public function getModerationReason() + { + return $this->container['moderation_reason']; + } + + /** + * Sets moderation_reason + * + * @param string|null $moderation_reason Статус модерации. + * + * @return self + */ + public function setModerationReason($moderation_reason) + { + if (is_null($moderation_reason)) { + throw new \InvalidArgumentException('non-nullable moderation_reason cannot be null'); + } + $this->container['moderation_reason'] = $moderation_reason; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/FullOutletLicenseDTO.php b/erp24/lib/yandex_market_api/Model/FullOutletLicenseDTO.php new file mode 100644 index 00000000..b17f2b69 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/FullOutletLicenseDTO.php @@ -0,0 +1,672 @@ + + */ +class FullOutletLicenseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'FullOutletLicenseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'outlet_id' => 'int', + 'license_type' => '\OpenAPI\Client\Model\LicenseType', + 'number' => 'string', + 'date_of_issue' => '\DateTime', + 'date_of_expiry' => '\DateTime', + 'check_status' => '\OpenAPI\Client\Model\LicenseCheckStatusType', + 'check_comment' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'outlet_id' => 'int64', + 'license_type' => null, + 'number' => null, + 'date_of_issue' => 'date-time', + 'date_of_expiry' => 'date-time', + 'check_status' => null, + 'check_comment' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'outlet_id' => false, + 'license_type' => false, + 'number' => false, + 'date_of_issue' => false, + 'date_of_expiry' => false, + 'check_status' => false, + 'check_comment' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'outlet_id' => 'outletId', + 'license_type' => 'licenseType', + 'number' => 'number', + 'date_of_issue' => 'dateOfIssue', + 'date_of_expiry' => 'dateOfExpiry', + 'check_status' => 'checkStatus', + 'check_comment' => 'checkComment' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'outlet_id' => 'setOutletId', + 'license_type' => 'setLicenseType', + 'number' => 'setNumber', + 'date_of_issue' => 'setDateOfIssue', + 'date_of_expiry' => 'setDateOfExpiry', + 'check_status' => 'setCheckStatus', + 'check_comment' => 'setCheckComment' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'outlet_id' => 'getOutletId', + 'license_type' => 'getLicenseType', + 'number' => 'getNumber', + 'date_of_issue' => 'getDateOfIssue', + 'date_of_expiry' => 'getDateOfExpiry', + 'check_status' => 'getCheckStatus', + 'check_comment' => 'getCheckComment' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('outlet_id', $data ?? [], null); + $this->setIfExists('license_type', $data ?? [], null); + $this->setIfExists('number', $data ?? [], null); + $this->setIfExists('date_of_issue', $data ?? [], null); + $this->setIfExists('date_of_expiry', $data ?? [], null); + $this->setIfExists('check_status', $data ?? [], null); + $this->setIfExists('check_comment', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['outlet_id'] === null) { + $invalidProperties[] = "'outlet_id' can't be null"; + } + if (($this->container['outlet_id'] < 1)) { + $invalidProperties[] = "invalid value for 'outlet_id', must be bigger than or equal to 1."; + } + + if ($this->container['license_type'] === null) { + $invalidProperties[] = "'license_type' can't be null"; + } + if ($this->container['number'] === null) { + $invalidProperties[] = "'number' can't be null"; + } + if ($this->container['date_of_issue'] === null) { + $invalidProperties[] = "'date_of_issue' can't be null"; + } + if ($this->container['date_of_expiry'] === null) { + $invalidProperties[] = "'date_of_expiry' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор лицензии. Параметр указывается, только если нужно изменить информацию о существующей лицензии. Ее идентификатор можно узнать с помощью запроса [GET campaigns/{campaignId}/outlets/licenses](../../reference/outlets/getOutletLicenses.md). При передаче информации о новой лицензии указывать идентификатор не нужно. Идентификатор лицензии присваивается Маркетом. Не путайте его с номером, указанным на лицензии: он передается в параметре `number`. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets outlet_id + * + * @return int + */ + public function getOutletId() + { + return $this->container['outlet_id']; + } + + /** + * Sets outlet_id + * + * @param int $outlet_id Идентификатор точки продаж, для которой действительна лицензия. + * + * @return self + */ + public function setOutletId($outlet_id) + { + if (is_null($outlet_id)) { + throw new \InvalidArgumentException('non-nullable outlet_id cannot be null'); + } + + if (($outlet_id < 1)) { + throw new \InvalidArgumentException('invalid value for $outlet_id when calling FullOutletLicenseDTO., must be bigger than or equal to 1.'); + } + + $this->container['outlet_id'] = $outlet_id; + + return $this; + } + + /** + * Gets license_type + * + * @return \OpenAPI\Client\Model\LicenseType + */ + public function getLicenseType() + { + return $this->container['license_type']; + } + + /** + * Sets license_type + * + * @param \OpenAPI\Client\Model\LicenseType $license_type license_type + * + * @return self + */ + public function setLicenseType($license_type) + { + if (is_null($license_type)) { + throw new \InvalidArgumentException('non-nullable license_type cannot be null'); + } + $this->container['license_type'] = $license_type; + + return $this; + } + + /** + * Gets number + * + * @return string + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param string $number Номер лицензии. + * + * @return self + */ + public function setNumber($number) + { + if (is_null($number)) { + throw new \InvalidArgumentException('non-nullable number cannot be null'); + } + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets date_of_issue + * + * @return \DateTime + */ + public function getDateOfIssue() + { + return $this->container['date_of_issue']; + } + + /** + * Sets date_of_issue + * + * @param \DateTime $date_of_issue Дата выдачи лицензии. Формат даты: ISO 8601 со смещением относительно UTC. Нужно передать дату, указанную на лицензии, время `00:00:00` и часовой пояс, соответствующий региону точки продаж. Например, если лицензия для точки продаж в Москве выдана 13 ноября 2017 года, то параметр должен иметь значение `2017-11-13T00:00:00+03:00`. Не может быть позже даты окончания срока действия, указанной в параметре `dateOfExpiry`. + * + * @return self + */ + public function setDateOfIssue($date_of_issue) + { + if (is_null($date_of_issue)) { + throw new \InvalidArgumentException('non-nullable date_of_issue cannot be null'); + } + $this->container['date_of_issue'] = $date_of_issue; + + return $this; + } + + /** + * Gets date_of_expiry + * + * @return \DateTime + */ + public function getDateOfExpiry() + { + return $this->container['date_of_expiry']; + } + + /** + * Sets date_of_expiry + * + * @param \DateTime $date_of_expiry Дата окончания действия лицензии. Формат даты: ISO 8601 со смещением относительно UTC. Нужно передать дату, указанную на лицензии, время `00:00:00` и часовой пояс, соответствующий региону точки продаж. Например, если действие лицензии для точки продаж в Москве заканчивается 20 ноября 2022 года, то параметр должен иметь значение `2022-11-20T00:00:00+03:00`. Не может быть раньше даты выдачи, указанной в параметре `dateOfIssue`. + * + * @return self + */ + public function setDateOfExpiry($date_of_expiry) + { + if (is_null($date_of_expiry)) { + throw new \InvalidArgumentException('non-nullable date_of_expiry cannot be null'); + } + $this->container['date_of_expiry'] = $date_of_expiry; + + return $this; + } + + /** + * Gets check_status + * + * @return \OpenAPI\Client\Model\LicenseCheckStatusType|null + */ + public function getCheckStatus() + { + return $this->container['check_status']; + } + + /** + * Sets check_status + * + * @param \OpenAPI\Client\Model\LicenseCheckStatusType|null $check_status check_status + * + * @return self + */ + public function setCheckStatus($check_status) + { + if (is_null($check_status)) { + throw new \InvalidArgumentException('non-nullable check_status cannot be null'); + } + $this->container['check_status'] = $check_status; + + return $this; + } + + /** + * Gets check_comment + * + * @return string|null + */ + public function getCheckComment() + { + return $this->container['check_comment']; + } + + /** + * Sets check_comment + * + * @param string|null $check_comment Причина, по которой лицензия не прошла проверку. Параметр возвращается, только если параметр `checkStatus` имеет значение `FAIL`. + * + * @return self + */ + public function setCheckComment($check_comment) + { + if (is_null($check_comment)) { + throw new \InvalidArgumentException('non-nullable check_comment cannot be null'); + } + $this->container['check_comment'] = $check_comment; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateBoostConsolidatedRequest.php b/erp24/lib/yandex_market_api/Model/GenerateBoostConsolidatedRequest.php new file mode 100644 index 00000000..3e854824 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateBoostConsolidatedRequest.php @@ -0,0 +1,487 @@ + + */ +class GenerateBoostConsolidatedRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateBoostConsolidatedRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'date_from' => '\DateTime', + 'date_to' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'date_from' => 'date', + 'date_to' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'date_from' => false, + 'date_to' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['business_id'] === null) { + $invalidProperties[] = "'business_id' can't be null"; + } + if ($this->container['date_from'] === null) { + $invalidProperties[] = "'date_from' can't be null"; + } + if ($this->container['date_to'] === null) { + $invalidProperties[] = "'date_to' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int $business_id Идентификатор бизнеса. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets date_from + * + * @return \DateTime + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime $date_from Начало периода, включительно. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime $date_to Конец периода, включительно. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateCompetitorsPositionReportRequest.php b/erp24/lib/yandex_market_api/Model/GenerateCompetitorsPositionReportRequest.php new file mode 100644 index 00000000..e54905e3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateCompetitorsPositionReportRequest.php @@ -0,0 +1,524 @@ + + */ +class GenerateCompetitorsPositionReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateCompetitorsPositionReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'category_id' => 'int', + 'date_from' => '\DateTime', + 'date_to' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'category_id' => 'int64', + 'date_from' => 'date', + 'date_to' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'category_id' => false, + 'date_from' => false, + 'date_to' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'category_id' => 'categoryId', + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'category_id' => 'setCategoryId', + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'category_id' => 'getCategoryId', + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('category_id', $data ?? [], null); + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['business_id'] === null) { + $invalidProperties[] = "'business_id' can't be null"; + } + if ($this->container['category_id'] === null) { + $invalidProperties[] = "'category_id' can't be null"; + } + if ($this->container['date_from'] === null) { + $invalidProperties[] = "'date_from' can't be null"; + } + if ($this->container['date_to'] === null) { + $invalidProperties[] = "'date_to' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int $business_id Идентификатор бизнеса. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets category_id + * + * @return int + */ + public function getCategoryId() + { + return $this->container['category_id']; + } + + /** + * Sets category_id + * + * @param int $category_id Идентификатор категории. + * + * @return self + */ + public function setCategoryId($category_id) + { + if (is_null($category_id)) { + throw new \InvalidArgumentException('non-nullable category_id cannot be null'); + } + $this->container['category_id'] = $category_id; + + return $this; + } + + /** + * Gets date_from + * + * @return \DateTime + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime $date_from Начало периода, включительно. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime $date_to Конец периода, включительно. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateGoodsFeedbackRequest.php b/erp24/lib/yandex_market_api/Model/GenerateGoodsFeedbackRequest.php new file mode 100644 index 00000000..d8bc3940 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateGoodsFeedbackRequest.php @@ -0,0 +1,413 @@ + + */ +class GenerateGoodsFeedbackRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateGoodsFeedbackRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['business_id'] === null) { + $invalidProperties[] = "'business_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int $business_id Идентификатор бизнеса. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateGoodsMovementReportRequest.php b/erp24/lib/yandex_market_api/Model/GenerateGoodsMovementReportRequest.php new file mode 100644 index 00000000..1ca60179 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateGoodsMovementReportRequest.php @@ -0,0 +1,552 @@ + + */ +class GenerateGoodsMovementReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateGoodsMovementReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'shop_sku' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'date_from' => 'date', + 'date_to' => 'date', + 'shop_sku' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'date_from' => false, + 'date_to' => false, + 'shop_sku' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'shop_sku' => 'shopSku' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'shop_sku' => 'setShopSku' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'shop_sku' => 'getShopSku' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('shop_sku', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + if (($this->container['campaign_id'] < 1)) { + $invalidProperties[] = "invalid value for 'campaign_id', must be bigger than or equal to 1."; + } + + if ($this->container['date_from'] === null) { + $invalidProperties[] = "'date_from' can't be null"; + } + if ($this->container['date_to'] === null) { + $invalidProperties[] = "'date_to' can't be null"; + } + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор кампании. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + + if (($campaign_id < 1)) { + throw new \InvalidArgumentException('invalid value for $campaign_id when calling GenerateGoodsMovementReportRequest., must be bigger than or equal to 1.'); + } + + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets date_from + * + * @return \DateTime + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime $date_from Начало периода, включительно. Формат даты: `ГГГГ-ММ-ДД`. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime $date_to Конец периода, включительно. Формат даты: `ГГГГ-ММ-ДД`. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets shop_sku + * + * @return string|null + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string|null $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling GenerateGoodsMovementReportRequest., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling GenerateGoodsMovementReportRequest., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling GenerateGoodsMovementReportRequest., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateGoodsRealizationReportRequest.php b/erp24/lib/yandex_market_api/Model/GenerateGoodsRealizationReportRequest.php new file mode 100644 index 00000000..be1fb6b7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateGoodsRealizationReportRequest.php @@ -0,0 +1,503 @@ + + */ +class GenerateGoodsRealizationReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateGoodsRealizationReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'year' => 'int', + 'month' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'year' => 'int32', + 'month' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'year' => false, + 'month' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'year' => 'year', + 'month' => 'month' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'year' => 'setYear', + 'month' => 'setMonth' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'year' => 'getYear', + 'month' => 'getMonth' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('year', $data ?? [], null); + $this->setIfExists('month', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + if ($this->container['year'] === null) { + $invalidProperties[] = "'year' can't be null"; + } + if ($this->container['month'] === null) { + $invalidProperties[] = "'month' can't be null"; + } + if (($this->container['month'] > 12)) { + $invalidProperties[] = "invalid value for 'month', must be smaller than or equal to 12."; + } + + if (($this->container['month'] < 1)) { + $invalidProperties[] = "invalid value for 'month', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор кампании. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets year + * + * @return int + */ + public function getYear() + { + return $this->container['year']; + } + + /** + * Sets year + * + * @param int $year Год. + * + * @return self + */ + public function setYear($year) + { + if (is_null($year)) { + throw new \InvalidArgumentException('non-nullable year cannot be null'); + } + $this->container['year'] = $year; + + return $this; + } + + /** + * Gets month + * + * @return int + */ + public function getMonth() + { + return $this->container['month']; + } + + /** + * Sets month + * + * @param int $month Номер месяца. + * + * @return self + */ + public function setMonth($month) + { + if (is_null($month)) { + throw new \InvalidArgumentException('non-nullable month cannot be null'); + } + + if (($month > 12)) { + throw new \InvalidArgumentException('invalid value for $month when calling GenerateGoodsRealizationReportRequest., must be smaller than or equal to 12.'); + } + if (($month < 1)) { + throw new \InvalidArgumentException('invalid value for $month when calling GenerateGoodsRealizationReportRequest., must be bigger than or equal to 1.'); + } + + $this->container['month'] = $month; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateGoodsTurnoverRequest.php b/erp24/lib/yandex_market_api/Model/GenerateGoodsTurnoverRequest.php new file mode 100644 index 00000000..a62cc3fa --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateGoodsTurnoverRequest.php @@ -0,0 +1,447 @@ + + */ +class GenerateGoodsTurnoverRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateGoodsTurnoverRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'date' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'date' => 'date' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'date' => 'setDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'date' => 'getDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор кампании. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets date + * + * @return \DateTime|null + */ + public function getDate() + { + return $this->container['date']; + } + + /** + * Sets date + * + * @param \DateTime|null $date Дата, за которую нужно рассчитать оборачиваемость. Если параметр не указан, используется текущая дата. + * + * @return self + */ + public function setDate($date) + { + if (is_null($date)) { + throw new \InvalidArgumentException('non-nullable date cannot be null'); + } + $this->container['date'] = $date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateMassOrderLabelsRequest.php b/erp24/lib/yandex_market_api/Model/GenerateMassOrderLabelsRequest.php new file mode 100644 index 00000000..53c79b34 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateMassOrderLabelsRequest.php @@ -0,0 +1,499 @@ + + */ +class GenerateMassOrderLabelsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateMassOrderLabelsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'order_ids' => 'int[]', + 'sorting_type' => '\OpenAPI\Client\Model\LabelsSortingType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'order_ids' => 'int64', + 'sorting_type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'order_ids' => false, + 'sorting_type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'order_ids' => 'orderIds', + 'sorting_type' => 'sortingType' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'order_ids' => 'setOrderIds', + 'sorting_type' => 'setSortingType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'order_ids' => 'getOrderIds', + 'sorting_type' => 'getSortingType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('order_ids', $data ?? [], null); + $this->setIfExists('sorting_type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['business_id'] === null) { + $invalidProperties[] = "'business_id' can't be null"; + } + if ($this->container['order_ids'] === null) { + $invalidProperties[] = "'order_ids' can't be null"; + } + if ((count($this->container['order_ids']) > 1000)) { + $invalidProperties[] = "invalid value for 'order_ids', number of items must be less than or equal to 1000."; + } + + if ((count($this->container['order_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'order_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int $business_id Идентификатор кабинета. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets order_ids + * + * @return int[] + */ + public function getOrderIds() + { + return $this->container['order_ids']; + } + + /** + * Sets order_ids + * + * @param int[] $order_ids Список идентификаторов заказов. + * + * @return self + */ + public function setOrderIds($order_ids) + { + if (is_null($order_ids)) { + throw new \InvalidArgumentException('non-nullable order_ids cannot be null'); + } + + if ((count($order_ids) > 1000)) { + throw new \InvalidArgumentException('invalid value for $order_ids when calling GenerateMassOrderLabelsRequest., number of items must be less than or equal to 1000.'); + } + if ((count($order_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $order_ids when calling GenerateMassOrderLabelsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['order_ids'] = $order_ids; + + return $this; + } + + /** + * Gets sorting_type + * + * @return \OpenAPI\Client\Model\LabelsSortingType|null + */ + public function getSortingType() + { + return $this->container['sorting_type']; + } + + /** + * Sets sorting_type + * + * @param \OpenAPI\Client\Model\LabelsSortingType|null $sorting_type sorting_type + * + * @return self + */ + public function setSortingType($sorting_type) + { + if (is_null($sorting_type)) { + throw new \InvalidArgumentException('non-nullable sorting_type cannot be null'); + } + $this->container['sorting_type'] = $sorting_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GeneratePricesReportRequest.php b/erp24/lib/yandex_market_api/Model/GeneratePricesReportRequest.php new file mode 100644 index 00000000..d4a51084 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GeneratePricesReportRequest.php @@ -0,0 +1,553 @@ + + */ +class GeneratePricesReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GeneratePricesReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'campaign_id' => 'int', + 'category_ids' => 'int[]', + 'creation_date_from' => '\DateTime', + 'creation_date_to' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'campaign_id' => 'int64', + 'category_ids' => 'int64', + 'creation_date_from' => 'date', + 'creation_date_to' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'campaign_id' => false, + 'category_ids' => true, + 'creation_date_from' => false, + 'creation_date_to' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'campaign_id' => 'campaignId', + 'category_ids' => 'categoryIds', + 'creation_date_from' => 'creationDateFrom', + 'creation_date_to' => 'creationDateTo' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'campaign_id' => 'setCampaignId', + 'category_ids' => 'setCategoryIds', + 'creation_date_from' => 'setCreationDateFrom', + 'creation_date_to' => 'setCreationDateTo' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'campaign_id' => 'getCampaignId', + 'category_ids' => 'getCategoryIds', + 'creation_date_from' => 'getCreationDateFrom', + 'creation_date_to' => 'getCreationDateTo' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('category_ids', $data ?? [], null); + $this->setIfExists('creation_date_from', $data ?? [], null); + $this->setIfExists('creation_date_to', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int|null + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int|null $business_id Идентификатор бизнеса. В большинстве случаев обязателен. Не указывается, если задан `campaignId`. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets campaign_id + * + * @return int|null + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int|null $campaign_id Идентификатор кампании. Как правило, не используется. Передавайте только если в кабинете есть магазины с уникальными ценами и вы хотите получить отчет для них. В этом случае передавать `businessId` не нужно. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets category_ids + * + * @return int[]|null + */ + public function getCategoryIds() + { + return $this->container['category_ids']; + } + + /** + * Sets category_ids + * + * @param int[]|null $category_ids Фильтр по категориям на Маркете. + * + * @return self + */ + public function setCategoryIds($category_ids) + { + if (is_null($category_ids)) { + array_push($this->openAPINullablesSetToNull, 'category_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('category_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['category_ids'] = $category_ids; + + return $this; + } + + /** + * Gets creation_date_from + * + * @return \DateTime|null + */ + public function getCreationDateFrom() + { + return $this->container['creation_date_from']; + } + + /** + * Sets creation_date_from + * + * @param \DateTime|null $creation_date_from Фильтр по времени появления предложения — начало периода. Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setCreationDateFrom($creation_date_from) + { + if (is_null($creation_date_from)) { + throw new \InvalidArgumentException('non-nullable creation_date_from cannot be null'); + } + $this->container['creation_date_from'] = $creation_date_from; + + return $this; + } + + /** + * Gets creation_date_to + * + * @return \DateTime|null + */ + public function getCreationDateTo() + { + return $this->container['creation_date_to']; + } + + /** + * Sets creation_date_to + * + * @param \DateTime|null $creation_date_to Фильтр по времени появления предложения — окончание периода. Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setCreationDateTo($creation_date_to) + { + if (is_null($creation_date_to)) { + throw new \InvalidArgumentException('non-nullable creation_date_to cannot be null'); + } + $this->container['creation_date_to'] = $creation_date_to; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateReportDTO.php b/erp24/lib/yandex_market_api/Model/GenerateReportDTO.php new file mode 100644 index 00000000..fb762b27 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateReportDTO.php @@ -0,0 +1,450 @@ + + */ +class GenerateReportDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateReportDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'report_id' => 'string', + 'estimated_generation_time' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'report_id' => null, + 'estimated_generation_time' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'report_id' => false, + 'estimated_generation_time' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'report_id' => 'reportId', + 'estimated_generation_time' => 'estimatedGenerationTime' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'report_id' => 'setReportId', + 'estimated_generation_time' => 'setEstimatedGenerationTime' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'report_id' => 'getReportId', + 'estimated_generation_time' => 'getEstimatedGenerationTime' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('report_id', $data ?? [], null); + $this->setIfExists('estimated_generation_time', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['report_id'] === null) { + $invalidProperties[] = "'report_id' can't be null"; + } + if ($this->container['estimated_generation_time'] === null) { + $invalidProperties[] = "'estimated_generation_time' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets report_id + * + * @return string + */ + public function getReportId() + { + return $this->container['report_id']; + } + + /** + * Sets report_id + * + * @param string $report_id Идентификатор, который понадобится для отслеживания статуса генерации и получения готового отчета. + * + * @return self + */ + public function setReportId($report_id) + { + if (is_null($report_id)) { + throw new \InvalidArgumentException('non-nullable report_id cannot be null'); + } + $this->container['report_id'] = $report_id; + + return $this; + } + + /** + * Gets estimated_generation_time + * + * @return int + */ + public function getEstimatedGenerationTime() + { + return $this->container['estimated_generation_time']; + } + + /** + * Sets estimated_generation_time + * + * @param int $estimated_generation_time Ожидаемая продолжительность генерации в миллисекундах. + * + * @return self + */ + public function setEstimatedGenerationTime($estimated_generation_time) + { + if (is_null($estimated_generation_time)) { + throw new \InvalidArgumentException('non-nullable estimated_generation_time cannot be null'); + } + $this->container['estimated_generation_time'] = $estimated_generation_time; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateReportResponse.php b/erp24/lib/yandex_market_api/Model/GenerateReportResponse.php new file mode 100644 index 00000000..7088d8bb --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateReportResponse.php @@ -0,0 +1,444 @@ + + */ +class GenerateReportResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateReportResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GenerateReportDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GenerateReportDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GenerateReportDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateShelfsStatisticsRequest.php b/erp24/lib/yandex_market_api/Model/GenerateShelfsStatisticsRequest.php new file mode 100644 index 00000000..c75c286d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateShelfsStatisticsRequest.php @@ -0,0 +1,524 @@ + + */ +class GenerateShelfsStatisticsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateShelfsStatisticsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'attribution_type' => '\OpenAPI\Client\Model\ShelfsStatisticsAttributionType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'date_from' => 'date', + 'date_to' => 'date', + 'attribution_type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'date_from' => false, + 'date_to' => false, + 'attribution_type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'attribution_type' => 'attributionType' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'attribution_type' => 'setAttributionType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'attribution_type' => 'getAttributionType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('attribution_type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['business_id'] === null) { + $invalidProperties[] = "'business_id' can't be null"; + } + if ($this->container['date_from'] === null) { + $invalidProperties[] = "'date_from' can't be null"; + } + if ($this->container['date_to'] === null) { + $invalidProperties[] = "'date_to' can't be null"; + } + if ($this->container['attribution_type'] === null) { + $invalidProperties[] = "'attribution_type' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int $business_id Идентификатор бизнеса. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets date_from + * + * @return \DateTime + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime $date_from Начало периода, включительно. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime $date_to Конец периода, включительно. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets attribution_type + * + * @return \OpenAPI\Client\Model\ShelfsStatisticsAttributionType + */ + public function getAttributionType() + { + return $this->container['attribution_type']; + } + + /** + * Sets attribution_type + * + * @param \OpenAPI\Client\Model\ShelfsStatisticsAttributionType $attribution_type attribution_type + * + * @return self + */ + public function setAttributionType($attribution_type) + { + if (is_null($attribution_type)) { + throw new \InvalidArgumentException('non-nullable attribution_type cannot be null'); + } + $this->container['attribution_type'] = $attribution_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateShipmentListDocumentReportRequest.php b/erp24/lib/yandex_market_api/Model/GenerateShipmentListDocumentReportRequest.php new file mode 100644 index 00000000..c96dcc2e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateShipmentListDocumentReportRequest.php @@ -0,0 +1,488 @@ + + */ +class GenerateShipmentListDocumentReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateShipmentListDocumentReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'shipment_id' => 'int', + 'order_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'shipment_id' => 'int64', + 'order_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'shipment_id' => false, + 'order_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'shipment_id' => 'shipmentId', + 'order_ids' => 'orderIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'shipment_id' => 'setShipmentId', + 'order_ids' => 'setOrderIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'shipment_id' => 'getShipmentId', + 'order_ids' => 'getOrderIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('shipment_id', $data ?? [], null); + $this->setIfExists('order_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор кампании. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets shipment_id + * + * @return int|null + */ + public function getShipmentId() + { + return $this->container['shipment_id']; + } + + /** + * Sets shipment_id + * + * @param int|null $shipment_id Идентификатор отгрузки. + * + * @return self + */ + public function setShipmentId($shipment_id) + { + if (is_null($shipment_id)) { + throw new \InvalidArgumentException('non-nullable shipment_id cannot be null'); + } + $this->container['shipment_id'] = $shipment_id; + + return $this; + } + + /** + * Gets order_ids + * + * @return int[]|null + */ + public function getOrderIds() + { + return $this->container['order_ids']; + } + + /** + * Sets order_ids + * + * @param int[]|null $order_ids Фильтр по идентификаторам заказа в отгрузке. + * + * @return self + */ + public function setOrderIds($order_ids) + { + if (is_null($order_ids)) { + array_push($this->openAPINullablesSetToNull, 'order_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['order_ids'] = $order_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateShowsSalesReportRequest.php b/erp24/lib/yandex_market_api/Model/GenerateShowsSalesReportRequest.php new file mode 100644 index 00000000..5d746a83 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateShowsSalesReportRequest.php @@ -0,0 +1,555 @@ + + */ +class GenerateShowsSalesReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateShowsSalesReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'campaign_id' => 'int', + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'grouping' => '\OpenAPI\Client\Model\ShowsSalesGroupingType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'campaign_id' => 'int64', + 'date_from' => 'date', + 'date_to' => 'date', + 'grouping' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'campaign_id' => false, + 'date_from' => false, + 'date_to' => false, + 'grouping' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'campaign_id' => 'campaignId', + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'grouping' => 'grouping' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'campaign_id' => 'setCampaignId', + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'grouping' => 'setGrouping' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'campaign_id' => 'getCampaignId', + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'grouping' => 'getGrouping' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('grouping', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['date_from'] === null) { + $invalidProperties[] = "'date_from' can't be null"; + } + if ($this->container['date_to'] === null) { + $invalidProperties[] = "'date_to' can't be null"; + } + if ($this->container['grouping'] === null) { + $invalidProperties[] = "'grouping' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int|null + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int|null $business_id Идентификатор бизнеса. Указывается, если нужно составить отчет по всем магазинам бизнеса. В запросе обязательно должен быть либо `businessID`, либо `campaignId`, но не оба сразу. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets campaign_id + * + * @return int|null + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int|null $campaign_id Идентификатор кампании. Указывается, если нужно составить отчет по конкретному магазину. В запросе обязательно должен быть либо `businessID`, либо `campaignId`, но не оба сразу. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets date_from + * + * @return \DateTime + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime $date_from Начало периода, включительно. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime $date_to Конец периода, включительно. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets grouping + * + * @return \OpenAPI\Client\Model\ShowsSalesGroupingType + */ + public function getGrouping() + { + return $this->container['grouping']; + } + + /** + * Sets grouping + * + * @param \OpenAPI\Client\Model\ShowsSalesGroupingType $grouping grouping + * + * @return self + */ + public function setGrouping($grouping) + { + if (is_null($grouping)) { + throw new \InvalidArgumentException('non-nullable grouping cannot be null'); + } + $this->container['grouping'] = $grouping; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateStocksOnWarehousesReportRequest.php b/erp24/lib/yandex_market_api/Model/GenerateStocksOnWarehousesReportRequest.php new file mode 100644 index 00000000..315146dd --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateStocksOnWarehousesReportRequest.php @@ -0,0 +1,563 @@ + + */ +class GenerateStocksOnWarehousesReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateStocksOnWarehousesReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'warehouse_ids' => 'int[]', + 'report_date' => '\DateTime', + 'category_ids' => 'int[]', + 'has_stocks' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'warehouse_ids' => 'int64', + 'report_date' => 'date', + 'category_ids' => 'int64', + 'has_stocks' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'warehouse_ids' => true, + 'report_date' => false, + 'category_ids' => true, + 'has_stocks' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'warehouse_ids' => 'warehouseIds', + 'report_date' => 'reportDate', + 'category_ids' => 'categoryIds', + 'has_stocks' => 'hasStocks' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'warehouse_ids' => 'setWarehouseIds', + 'report_date' => 'setReportDate', + 'category_ids' => 'setCategoryIds', + 'has_stocks' => 'setHasStocks' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'warehouse_ids' => 'getWarehouseIds', + 'report_date' => 'getReportDate', + 'category_ids' => 'getCategoryIds', + 'has_stocks' => 'getHasStocks' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('warehouse_ids', $data ?? [], null); + $this->setIfExists('report_date', $data ?? [], null); + $this->setIfExists('category_ids', $data ?? [], null); + $this->setIfExists('has_stocks', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор магазина. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets warehouse_ids + * + * @return int[]|null + */ + public function getWarehouseIds() + { + return $this->container['warehouse_ids']; + } + + /** + * Sets warehouse_ids + * + * @param int[]|null $warehouse_ids Фильтр по идентификаторам складов (только модель FBY). Чтобы узнать идентификатор, воспользуйтесь запросом [GET warehouses](../../reference/warehouses/getFulfillmentWarehouses.md). + * + * @return self + */ + public function setWarehouseIds($warehouse_ids) + { + if (is_null($warehouse_ids)) { + array_push($this->openAPINullablesSetToNull, 'warehouse_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('warehouse_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['warehouse_ids'] = $warehouse_ids; + + return $this; + } + + /** + * Gets report_date + * + * @return \DateTime|null + */ + public function getReportDate() + { + return $this->container['report_date']; + } + + /** + * Sets report_date + * + * @param \DateTime|null $report_date Фильтр по дате (для модели FBY). В отчет попадут данные за **предшествующий** дате день. + * + * @return self + */ + public function setReportDate($report_date) + { + if (is_null($report_date)) { + throw new \InvalidArgumentException('non-nullable report_date cannot be null'); + } + $this->container['report_date'] = $report_date; + + return $this; + } + + /** + * Gets category_ids + * + * @return int[]|null + */ + public function getCategoryIds() + { + return $this->container['category_ids']; + } + + /** + * Sets category_ids + * + * @param int[]|null $category_ids Фильтр по категориям на Маркете (кроме модели FBY). + * + * @return self + */ + public function setCategoryIds($category_ids) + { + if (is_null($category_ids)) { + array_push($this->openAPINullablesSetToNull, 'category_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('category_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['category_ids'] = $category_ids; + + return $this; + } + + /** + * Gets has_stocks + * + * @return bool|null + */ + public function getHasStocks() + { + return $this->container['has_stocks']; + } + + /** + * Sets has_stocks + * + * @param bool|null $has_stocks Фильтр по наличию остатков (кроме модели FBY). + * + * @return self + */ + public function setHasStocks($has_stocks) + { + if (is_null($has_stocks)) { + throw new \InvalidArgumentException('non-nullable has_stocks cannot be null'); + } + $this->container['has_stocks'] = $has_stocks; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateUnitedMarketplaceServicesReportRequest.php b/erp24/lib/yandex_market_api/Model/GenerateUnitedMarketplaceServicesReportRequest.php new file mode 100644 index 00000000..7e0bed3f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateUnitedMarketplaceServicesReportRequest.php @@ -0,0 +1,840 @@ + + */ +class GenerateUnitedMarketplaceServicesReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateUnitedMarketplaceServicesReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'date_time_from' => '\DateTime', + 'date_time_to' => '\DateTime', + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'year_from' => 'int', + 'month_from' => 'int', + 'year_to' => 'int', + 'month_to' => 'int', + 'placement_programs' => '\OpenAPI\Client\Model\PlacementType[]', + 'inns' => 'string[]', + 'campaign_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'date_time_from' => 'date-time', + 'date_time_to' => 'date-time', + 'date_from' => 'date', + 'date_to' => 'date', + 'year_from' => 'int32', + 'month_from' => 'int32', + 'year_to' => 'int32', + 'month_to' => 'int32', + 'placement_programs' => null, + 'inns' => null, + 'campaign_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'date_time_from' => false, + 'date_time_to' => false, + 'date_from' => false, + 'date_to' => false, + 'year_from' => false, + 'month_from' => false, + 'year_to' => false, + 'month_to' => false, + 'placement_programs' => true, + 'inns' => true, + 'campaign_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'date_time_from' => 'dateTimeFrom', + 'date_time_to' => 'dateTimeTo', + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'year_from' => 'yearFrom', + 'month_from' => 'monthFrom', + 'year_to' => 'yearTo', + 'month_to' => 'monthTo', + 'placement_programs' => 'placementPrograms', + 'inns' => 'inns', + 'campaign_ids' => 'campaignIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'date_time_from' => 'setDateTimeFrom', + 'date_time_to' => 'setDateTimeTo', + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'year_from' => 'setYearFrom', + 'month_from' => 'setMonthFrom', + 'year_to' => 'setYearTo', + 'month_to' => 'setMonthTo', + 'placement_programs' => 'setPlacementPrograms', + 'inns' => 'setInns', + 'campaign_ids' => 'setCampaignIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'date_time_from' => 'getDateTimeFrom', + 'date_time_to' => 'getDateTimeTo', + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'year_from' => 'getYearFrom', + 'month_from' => 'getMonthFrom', + 'year_to' => 'getYearTo', + 'month_to' => 'getMonthTo', + 'placement_programs' => 'getPlacementPrograms', + 'inns' => 'getInns', + 'campaign_ids' => 'getCampaignIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('date_time_from', $data ?? [], null); + $this->setIfExists('date_time_to', $data ?? [], null); + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('year_from', $data ?? [], null); + $this->setIfExists('month_from', $data ?? [], null); + $this->setIfExists('year_to', $data ?? [], null); + $this->setIfExists('month_to', $data ?? [], null); + $this->setIfExists('placement_programs', $data ?? [], null); + $this->setIfExists('inns', $data ?? [], null); + $this->setIfExists('campaign_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['business_id'] === null) { + $invalidProperties[] = "'business_id' can't be null"; + } + if (!is_null($this->container['month_from']) && ($this->container['month_from'] > 12)) { + $invalidProperties[] = "invalid value for 'month_from', must be smaller than or equal to 12."; + } + + if (!is_null($this->container['month_from']) && ($this->container['month_from'] < 1)) { + $invalidProperties[] = "invalid value for 'month_from', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['month_to']) && ($this->container['month_to'] > 12)) { + $invalidProperties[] = "invalid value for 'month_to', must be smaller than or equal to 12."; + } + + if (!is_null($this->container['month_to']) && ($this->container['month_to'] < 1)) { + $invalidProperties[] = "invalid value for 'month_to', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int $business_id Идентификатор бизнеса. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets date_time_from + * + * @return \DateTime|null + */ + public function getDateTimeFrom() + { + return $this->container['date_time_from']; + } + + /** + * Sets date_time_from + * + * @param \DateTime|null $date_time_from {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Начало периода, включительно. + * + * @return self + */ + public function setDateTimeFrom($date_time_from) + { + if (is_null($date_time_from)) { + throw new \InvalidArgumentException('non-nullable date_time_from cannot be null'); + } + $this->container['date_time_from'] = $date_time_from; + + return $this; + } + + /** + * Gets date_time_to + * + * @return \DateTime|null + */ + public function getDateTimeTo() + { + return $this->container['date_time_to']; + } + + /** + * Sets date_time_to + * + * @param \DateTime|null $date_time_to {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Конец периода, включительно. Максимальный период — 3 месяца. + * + * @return self + */ + public function setDateTimeTo($date_time_to) + { + if (is_null($date_time_to)) { + throw new \InvalidArgumentException('non-nullable date_time_to cannot be null'); + } + $this->container['date_time_to'] = $date_time_to; + + return $this; + } + + /** + * Gets date_from + * + * @return \DateTime|null + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime|null $date_from Начало периода, включительно. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime|null + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime|null $date_to Конец периода, включительно. Максимальный период — 3 месяца. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets year_from + * + * @return int|null + */ + public function getYearFrom() + { + return $this->container['year_from']; + } + + /** + * Sets year_from + * + * @param int|null $year_from Начальный год формирования акта. + * + * @return self + */ + public function setYearFrom($year_from) + { + if (is_null($year_from)) { + throw new \InvalidArgumentException('non-nullable year_from cannot be null'); + } + $this->container['year_from'] = $year_from; + + return $this; + } + + /** + * Gets month_from + * + * @return int|null + */ + public function getMonthFrom() + { + return $this->container['month_from']; + } + + /** + * Sets month_from + * + * @param int|null $month_from Начальный номер месяца формирования акта. + * + * @return self + */ + public function setMonthFrom($month_from) + { + if (is_null($month_from)) { + throw new \InvalidArgumentException('non-nullable month_from cannot be null'); + } + + if (($month_from > 12)) { + throw new \InvalidArgumentException('invalid value for $month_from when calling GenerateUnitedMarketplaceServicesReportRequest., must be smaller than or equal to 12.'); + } + if (($month_from < 1)) { + throw new \InvalidArgumentException('invalid value for $month_from when calling GenerateUnitedMarketplaceServicesReportRequest., must be bigger than or equal to 1.'); + } + + $this->container['month_from'] = $month_from; + + return $this; + } + + /** + * Gets year_to + * + * @return int|null + */ + public function getYearTo() + { + return $this->container['year_to']; + } + + /** + * Sets year_to + * + * @param int|null $year_to Конечный год формирования акта. + * + * @return self + */ + public function setYearTo($year_to) + { + if (is_null($year_to)) { + throw new \InvalidArgumentException('non-nullable year_to cannot be null'); + } + $this->container['year_to'] = $year_to; + + return $this; + } + + /** + * Gets month_to + * + * @return int|null + */ + public function getMonthTo() + { + return $this->container['month_to']; + } + + /** + * Sets month_to + * + * @param int|null $month_to Конечный номер месяца формирования акта. + * + * @return self + */ + public function setMonthTo($month_to) + { + if (is_null($month_to)) { + throw new \InvalidArgumentException('non-nullable month_to cannot be null'); + } + + if (($month_to > 12)) { + throw new \InvalidArgumentException('invalid value for $month_to when calling GenerateUnitedMarketplaceServicesReportRequest., must be smaller than or equal to 12.'); + } + if (($month_to < 1)) { + throw new \InvalidArgumentException('invalid value for $month_to when calling GenerateUnitedMarketplaceServicesReportRequest., must be bigger than or equal to 1.'); + } + + $this->container['month_to'] = $month_to; + + return $this; + } + + /** + * Gets placement_programs + * + * @return \OpenAPI\Client\Model\PlacementType[]|null + */ + public function getPlacementPrograms() + { + return $this->container['placement_programs']; + } + + /** + * Sets placement_programs + * + * @param \OpenAPI\Client\Model\PlacementType[]|null $placement_programs Список моделей, которые нужны в отчете. + * + * @return self + */ + public function setPlacementPrograms($placement_programs) + { + if (is_null($placement_programs)) { + array_push($this->openAPINullablesSetToNull, 'placement_programs'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('placement_programs', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['placement_programs'] = $placement_programs; + + return $this; + } + + /** + * Gets inns + * + * @return string[]|null + */ + public function getInns() + { + return $this->container['inns']; + } + + /** + * Sets inns + * + * @param string[]|null $inns Список ИНН, которые нужны в отчете. + * + * @return self + */ + public function setInns($inns) + { + if (is_null($inns)) { + array_push($this->openAPINullablesSetToNull, 'inns'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('inns', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['inns'] = $inns; + + return $this; + } + + /** + * Gets campaign_ids + * + * @return int[]|null + */ + public function getCampaignIds() + { + return $this->container['campaign_ids']; + } + + /** + * Sets campaign_ids + * + * @param int[]|null $campaign_ids Список магазинов, которые нужны в отчете. + * + * @return self + */ + public function setCampaignIds($campaign_ids) + { + if (is_null($campaign_ids)) { + array_push($this->openAPINullablesSetToNull, 'campaign_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('campaign_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['campaign_ids'] = $campaign_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateUnitedNettingReportRequest.php b/erp24/lib/yandex_market_api/Model/GenerateUnitedNettingReportRequest.php new file mode 100644 index 00000000..1b7521b0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateUnitedNettingReportRequest.php @@ -0,0 +1,740 @@ + + */ +class GenerateUnitedNettingReportRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateUnitedNettingReportRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'date_time_from' => '\DateTime', + 'date_time_to' => '\DateTime', + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'bank_order_id' => 'int', + 'bank_order_date_time' => '\DateTime', + 'placement_programs' => '\OpenAPI\Client\Model\PlacementType[]', + 'inns' => 'string[]', + 'campaign_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'date_time_from' => 'date-time', + 'date_time_to' => 'date-time', + 'date_from' => 'date', + 'date_to' => 'date', + 'bank_order_id' => 'int64', + 'bank_order_date_time' => 'date-time', + 'placement_programs' => null, + 'inns' => null, + 'campaign_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'date_time_from' => false, + 'date_time_to' => false, + 'date_from' => false, + 'date_to' => false, + 'bank_order_id' => false, + 'bank_order_date_time' => false, + 'placement_programs' => true, + 'inns' => true, + 'campaign_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'date_time_from' => 'dateTimeFrom', + 'date_time_to' => 'dateTimeTo', + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'bank_order_id' => 'bankOrderId', + 'bank_order_date_time' => 'bankOrderDateTime', + 'placement_programs' => 'placementPrograms', + 'inns' => 'inns', + 'campaign_ids' => 'campaignIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'date_time_from' => 'setDateTimeFrom', + 'date_time_to' => 'setDateTimeTo', + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'bank_order_id' => 'setBankOrderId', + 'bank_order_date_time' => 'setBankOrderDateTime', + 'placement_programs' => 'setPlacementPrograms', + 'inns' => 'setInns', + 'campaign_ids' => 'setCampaignIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'date_time_from' => 'getDateTimeFrom', + 'date_time_to' => 'getDateTimeTo', + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'bank_order_id' => 'getBankOrderId', + 'bank_order_date_time' => 'getBankOrderDateTime', + 'placement_programs' => 'getPlacementPrograms', + 'inns' => 'getInns', + 'campaign_ids' => 'getCampaignIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('date_time_from', $data ?? [], null); + $this->setIfExists('date_time_to', $data ?? [], null); + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('bank_order_id', $data ?? [], null); + $this->setIfExists('bank_order_date_time', $data ?? [], null); + $this->setIfExists('placement_programs', $data ?? [], null); + $this->setIfExists('inns', $data ?? [], null); + $this->setIfExists('campaign_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['business_id'] === null) { + $invalidProperties[] = "'business_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int $business_id Идентификатор бизнеса. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets date_time_from + * + * @return \DateTime|null + */ + public function getDateTimeFrom() + { + return $this->container['date_time_from']; + } + + /** + * Sets date_time_from + * + * @param \DateTime|null $date_time_from {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Начало периода, включительно. + * + * @return self + */ + public function setDateTimeFrom($date_time_from) + { + if (is_null($date_time_from)) { + throw new \InvalidArgumentException('non-nullable date_time_from cannot be null'); + } + $this->container['date_time_from'] = $date_time_from; + + return $this; + } + + /** + * Gets date_time_to + * + * @return \DateTime|null + */ + public function getDateTimeTo() + { + return $this->container['date_time_to']; + } + + /** + * Sets date_time_to + * + * @param \DateTime|null $date_time_to {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Конец периода, включительно. Максимальный период — 3 месяца. + * + * @return self + */ + public function setDateTimeTo($date_time_to) + { + if (is_null($date_time_to)) { + throw new \InvalidArgumentException('non-nullable date_time_to cannot be null'); + } + $this->container['date_time_to'] = $date_time_to; + + return $this; + } + + /** + * Gets date_from + * + * @return \DateTime|null + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime|null $date_from Начало периода, включительно. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime|null + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime|null $date_to Конец периода, включительно. Максимальный период — 3 месяца. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets bank_order_id + * + * @return int|null + */ + public function getBankOrderId() + { + return $this->container['bank_order_id']; + } + + /** + * Sets bank_order_id + * + * @param int|null $bank_order_id Номер платежного поручения. + * + * @return self + */ + public function setBankOrderId($bank_order_id) + { + if (is_null($bank_order_id)) { + throw new \InvalidArgumentException('non-nullable bank_order_id cannot be null'); + } + $this->container['bank_order_id'] = $bank_order_id; + + return $this; + } + + /** + * Gets bank_order_date_time + * + * @return \DateTime|null + */ + public function getBankOrderDateTime() + { + return $this->container['bank_order_date_time']; + } + + /** + * Sets bank_order_date_time + * + * @param \DateTime|null $bank_order_date_time Дата платежного поручения. + * + * @return self + */ + public function setBankOrderDateTime($bank_order_date_time) + { + if (is_null($bank_order_date_time)) { + throw new \InvalidArgumentException('non-nullable bank_order_date_time cannot be null'); + } + $this->container['bank_order_date_time'] = $bank_order_date_time; + + return $this; + } + + /** + * Gets placement_programs + * + * @return \OpenAPI\Client\Model\PlacementType[]|null + */ + public function getPlacementPrograms() + { + return $this->container['placement_programs']; + } + + /** + * Sets placement_programs + * + * @param \OpenAPI\Client\Model\PlacementType[]|null $placement_programs Список моделей, которые нужны в отчете. + * + * @return self + */ + public function setPlacementPrograms($placement_programs) + { + if (is_null($placement_programs)) { + array_push($this->openAPINullablesSetToNull, 'placement_programs'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('placement_programs', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['placement_programs'] = $placement_programs; + + return $this; + } + + /** + * Gets inns + * + * @return string[]|null + */ + public function getInns() + { + return $this->container['inns']; + } + + /** + * Sets inns + * + * @param string[]|null $inns Список ИНН, которые нужны в отчете. + * + * @return self + */ + public function setInns($inns) + { + if (is_null($inns)) { + array_push($this->openAPINullablesSetToNull, 'inns'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('inns', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['inns'] = $inns; + + return $this; + } + + /** + * Gets campaign_ids + * + * @return int[]|null + */ + public function getCampaignIds() + { + return $this->container['campaign_ids']; + } + + /** + * Sets campaign_ids + * + * @param int[]|null $campaign_ids Список магазинов, которые нужны в отчете. + * + * @return self + */ + public function setCampaignIds($campaign_ids) + { + if (is_null($campaign_ids)) { + array_push($this->openAPINullablesSetToNull, 'campaign_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('campaign_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['campaign_ids'] = $campaign_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GenerateUnitedOrdersRequest.php b/erp24/lib/yandex_market_api/Model/GenerateUnitedOrdersRequest.php new file mode 100644 index 00000000..11c70225 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GenerateUnitedOrdersRequest.php @@ -0,0 +1,562 @@ + + */ +class GenerateUnitedOrdersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GenerateUnitedOrdersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'business_id' => 'int', + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'campaign_ids' => 'int[]', + 'promo_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'business_id' => 'int64', + 'date_from' => 'date', + 'date_to' => 'date', + 'campaign_ids' => 'int64', + 'promo_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'business_id' => false, + 'date_from' => false, + 'date_to' => false, + 'campaign_ids' => true, + 'promo_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'business_id' => 'businessId', + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'campaign_ids' => 'campaignIds', + 'promo_id' => 'promoId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'business_id' => 'setBusinessId', + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'campaign_ids' => 'setCampaignIds', + 'promo_id' => 'setPromoId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'business_id' => 'getBusinessId', + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'campaign_ids' => 'getCampaignIds', + 'promo_id' => 'getPromoId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('business_id', $data ?? [], null); + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('campaign_ids', $data ?? [], null); + $this->setIfExists('promo_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['business_id'] === null) { + $invalidProperties[] = "'business_id' can't be null"; + } + if ($this->container['date_from'] === null) { + $invalidProperties[] = "'date_from' can't be null"; + } + if ($this->container['date_to'] === null) { + $invalidProperties[] = "'date_to' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets business_id + * + * @return int + */ + public function getBusinessId() + { + return $this->container['business_id']; + } + + /** + * Sets business_id + * + * @param int $business_id Идентификатор бизнеса. + * + * @return self + */ + public function setBusinessId($business_id) + { + if (is_null($business_id)) { + throw new \InvalidArgumentException('non-nullable business_id cannot be null'); + } + $this->container['business_id'] = $business_id; + + return $this; + } + + /** + * Gets date_from + * + * @return \DateTime + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime $date_from Начало периода, включительно. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime $date_to Конец периода, включительно. Максимальный период — 1 год. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets campaign_ids + * + * @return int[]|null + */ + public function getCampaignIds() + { + return $this->container['campaign_ids']; + } + + /** + * Sets campaign_ids + * + * @param int[]|null $campaign_ids Список магазинов, которые нужны в отчете. + * + * @return self + */ + public function setCampaignIds($campaign_ids) + { + if (is_null($campaign_ids)) { + array_push($this->openAPINullablesSetToNull, 'campaign_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('campaign_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['campaign_ids'] = $campaign_ids; + + return $this; + } + + /** + * Gets promo_id + * + * @return string|null + */ + public function getPromoId() + { + return $this->container['promo_id']; + } + + /** + * Sets promo_id + * + * @param string|null $promo_id Идентификатор акции, товары из которой нужны в отчете. + * + * @return self + */ + public function setPromoId($promo_id) + { + if (is_null($promo_id)) { + throw new \InvalidArgumentException('non-nullable promo_id cannot be null'); + } + $this->container['promo_id'] = $promo_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetAllOffersResponse.php b/erp24/lib/yandex_market_api/Model/GetAllOffersResponse.php new file mode 100644 index 00000000..f989b137 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetAllOffersResponse.php @@ -0,0 +1,413 @@ + + */ +class GetAllOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetAllOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\OfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\OfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\OfferDTO[] $offers Список предложений магазина. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBidsInfoRequest.php b/erp24/lib/yandex_market_api/Model/GetBidsInfoRequest.php new file mode 100644 index 00000000..420c5b93 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBidsInfoRequest.php @@ -0,0 +1,432 @@ + + */ +class GetBidsInfoRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBidsInfoRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'skus' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'skus' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'skus' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'skus' => 'skus' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'skus' => 'setSkus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'skus' => 'getSkus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('skus', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['skus']) && (count($this->container['skus']) > 1500)) { + $invalidProperties[] = "invalid value for 'skus', number of items must be less than or equal to 1500."; + } + + if (!is_null($this->container['skus']) && (count($this->container['skus']) < 1)) { + $invalidProperties[] = "invalid value for 'skus', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets skus + * + * @return string[]|null + */ + public function getSkus() + { + return $this->container['skus']; + } + + /** + * Sets skus + * + * @param string[]|null $skus Список товаров, для которых нужно получить значения ставок. Если список не задан, постранично возвращаются все товары со ставками. Если список задан, результаты возвращаются одной страницей, а параметры `page_token` и `limit` игнорируются. + * + * @return self + */ + public function setSkus($skus) + { + if (is_null($skus)) { + array_push($this->openAPINullablesSetToNull, 'skus'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('skus', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($skus) && (count($skus) > 1500)) { + throw new \InvalidArgumentException('invalid value for $skus when calling GetBidsInfoRequest., number of items must be less than or equal to 1500.'); + } + if (!is_null($skus) && (count($skus) < 1)) { + throw new \InvalidArgumentException('invalid length for $skus when calling GetBidsInfoRequest., number of items must be greater than or equal to 1.'); + } + $this->container['skus'] = $skus; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBidsInfoResponse.php b/erp24/lib/yandex_market_api/Model/GetBidsInfoResponse.php new file mode 100644 index 00000000..f91d60f6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBidsInfoResponse.php @@ -0,0 +1,444 @@ + + */ +class GetBidsInfoResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBidsInfoResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetBidsInfoResponseDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetBidsInfoResponseDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetBidsInfoResponseDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBidsInfoResponseDTO.php b/erp24/lib/yandex_market_api/Model/GetBidsInfoResponseDTO.php new file mode 100644 index 00000000..b75c8cf4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBidsInfoResponseDTO.php @@ -0,0 +1,447 @@ + + */ +class GetBidsInfoResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBidsInfoResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bids' => '\OpenAPI\Client\Model\SkuBidItemDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bids' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bids' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bids' => 'bids', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bids' => 'setBids', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bids' => 'getBids', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('bids', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['bids'] === null) { + $invalidProperties[] = "'bids' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets bids + * + * @return \OpenAPI\Client\Model\SkuBidItemDTO[] + */ + public function getBids() + { + return $this->container['bids']; + } + + /** + * Sets bids + * + * @param \OpenAPI\Client\Model\SkuBidItemDTO[] $bids Страница списка товаров. + * + * @return self + */ + public function setBids($bids) + { + if (is_null($bids)) { + throw new \InvalidArgumentException('non-nullable bids cannot be null'); + } + $this->container['bids'] = $bids; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsRequest.php b/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsRequest.php new file mode 100644 index 00000000..4b0eb5ff --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsRequest.php @@ -0,0 +1,428 @@ + + */ +class GetBidsRecommendationsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBidsRecommendationsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'skus' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'skus' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'skus' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'skus' => 'skus' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'skus' => 'setSkus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'skus' => 'getSkus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('skus', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['skus'] === null) { + $invalidProperties[] = "'skus' can't be null"; + } + if ((count($this->container['skus']) > 1500)) { + $invalidProperties[] = "invalid value for 'skus', number of items must be less than or equal to 1500."; + } + + if ((count($this->container['skus']) < 1)) { + $invalidProperties[] = "invalid value for 'skus', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets skus + * + * @return string[] + */ + public function getSkus() + { + return $this->container['skus']; + } + + /** + * Sets skus + * + * @param string[] $skus Список товаров, для которых нужно получить рекомендации по ставкам. + * + * @return self + */ + public function setSkus($skus) + { + if (is_null($skus)) { + throw new \InvalidArgumentException('non-nullable skus cannot be null'); + } + + if ((count($skus) > 1500)) { + throw new \InvalidArgumentException('invalid value for $skus when calling GetBidsRecommendationsRequest., number of items must be less than or equal to 1500.'); + } + if ((count($skus) < 1)) { + throw new \InvalidArgumentException('invalid length for $skus when calling GetBidsRecommendationsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['skus'] = $skus; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsResponse.php b/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsResponse.php new file mode 100644 index 00000000..c81aa09a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsResponse.php @@ -0,0 +1,444 @@ + + */ +class GetBidsRecommendationsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBidsRecommendationsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetBidsRecommendationsResponseDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetBidsRecommendationsResponseDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetBidsRecommendationsResponseDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsResponseDTO.php b/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsResponseDTO.php new file mode 100644 index 00000000..6a3a5313 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBidsRecommendationsResponseDTO.php @@ -0,0 +1,413 @@ + + */ +class GetBidsRecommendationsResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBidsRecommendationsResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'recommendations' => '\OpenAPI\Client\Model\SkuBidRecommendationItemDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'recommendations' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'recommendations' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'recommendations' => 'recommendations' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'recommendations' => 'setRecommendations' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'recommendations' => 'getRecommendations' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('recommendations', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['recommendations'] === null) { + $invalidProperties[] = "'recommendations' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets recommendations + * + * @return \OpenAPI\Client\Model\SkuBidRecommendationItemDTO[] + */ + public function getRecommendations() + { + return $this->container['recommendations']; + } + + /** + * Sets recommendations + * + * @param \OpenAPI\Client\Model\SkuBidRecommendationItemDTO[] $recommendations Список товаров с рекомендованными ставками. + * + * @return self + */ + public function setRecommendations($recommendations) + { + if (is_null($recommendations)) { + throw new \InvalidArgumentException('non-nullable recommendations cannot be null'); + } + $this->container['recommendations'] = $recommendations; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBusinessBuyerInfoResponse.php b/erp24/lib/yandex_market_api/Model/GetBusinessBuyerInfoResponse.php new file mode 100644 index 00000000..160a9727 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBusinessBuyerInfoResponse.php @@ -0,0 +1,443 @@ + + */ +class GetBusinessBuyerInfoResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBusinessBuyerInfoResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OrderBusinessBuyerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OrderBusinessBuyerDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OrderBusinessBuyerDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBusinessDocumentsInfoResponse.php b/erp24/lib/yandex_market_api/Model/GetBusinessDocumentsInfoResponse.php new file mode 100644 index 00000000..d742f439 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBusinessDocumentsInfoResponse.php @@ -0,0 +1,443 @@ + + */ +class GetBusinessDocumentsInfoResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBusinessDocumentsInfoResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OrderBusinessDocumentsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OrderBusinessDocumentsDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OrderBusinessDocumentsDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBusinessSettingsInfoDTO.php b/erp24/lib/yandex_market_api/Model/GetBusinessSettingsInfoDTO.php new file mode 100644 index 00000000..8517967c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBusinessSettingsInfoDTO.php @@ -0,0 +1,444 @@ + + */ +class GetBusinessSettingsInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBusinessSettingsInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'info' => '\OpenAPI\Client\Model\BusinessDTO', + 'settings' => '\OpenAPI\Client\Model\BusinessSettingsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'info' => null, + 'settings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'info' => false, + 'settings' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'info' => 'info', + 'settings' => 'settings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'info' => 'setInfo', + 'settings' => 'setSettings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'info' => 'getInfo', + 'settings' => 'getSettings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('info', $data ?? [], null); + $this->setIfExists('settings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets info + * + * @return \OpenAPI\Client\Model\BusinessDTO|null + */ + public function getInfo() + { + return $this->container['info']; + } + + /** + * Sets info + * + * @param \OpenAPI\Client\Model\BusinessDTO|null $info info + * + * @return self + */ + public function setInfo($info) + { + if (is_null($info)) { + throw new \InvalidArgumentException('non-nullable info cannot be null'); + } + $this->container['info'] = $info; + + return $this; + } + + /** + * Gets settings + * + * @return \OpenAPI\Client\Model\BusinessSettingsDTO|null + */ + public function getSettings() + { + return $this->container['settings']; + } + + /** + * Sets settings + * + * @param \OpenAPI\Client\Model\BusinessSettingsDTO|null $settings settings + * + * @return self + */ + public function setSettings($settings) + { + if (is_null($settings)) { + throw new \InvalidArgumentException('non-nullable settings cannot be null'); + } + $this->container['settings'] = $settings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetBusinessSettingsResponse.php b/erp24/lib/yandex_market_api/Model/GetBusinessSettingsResponse.php new file mode 100644 index 00000000..62e10fcf --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetBusinessSettingsResponse.php @@ -0,0 +1,444 @@ + + */ +class GetBusinessSettingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetBusinessSettingsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetBusinessSettingsInfoDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetBusinessSettingsInfoDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetBusinessSettingsInfoDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignLoginsResponse.php b/erp24/lib/yandex_market_api/Model/GetCampaignLoginsResponse.php new file mode 100644 index 00000000..53564c88 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignLoginsResponse.php @@ -0,0 +1,413 @@ + + */ +class GetCampaignLoginsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignLoginsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'logins' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'logins' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'logins' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'logins' => 'logins' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'logins' => 'setLogins' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'logins' => 'getLogins' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('logins', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['logins'] === null) { + $invalidProperties[] = "'logins' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets logins + * + * @return string[] + */ + public function getLogins() + { + return $this->container['logins']; + } + + /** + * Sets logins + * + * @param string[] $logins Список логинов. + * + * @return self + */ + public function setLogins($logins) + { + if (is_null($logins)) { + throw new \InvalidArgumentException('non-nullable logins cannot be null'); + } + $this->container['logins'] = $logins; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignOfferDTO.php b/erp24/lib/yandex_market_api/Model/GetCampaignOfferDTO.php new file mode 100644 index 00000000..36724f51 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignOfferDTO.php @@ -0,0 +1,687 @@ + + */ +class GetCampaignOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'quantum' => '\OpenAPI\Client\Model\QuantumDTO', + 'available' => 'bool', + 'basic_price' => '\OpenAPI\Client\Model\GetPriceWithDiscountDTO', + 'campaign_price' => '\OpenAPI\Client\Model\GetPriceWithVatDTO', + 'status' => '\OpenAPI\Client\Model\OfferCampaignStatusType', + 'errors' => '\OpenAPI\Client\Model\OfferErrorDTO[]', + 'warnings' => '\OpenAPI\Client\Model\OfferErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'quantum' => null, + 'available' => null, + 'basic_price' => null, + 'campaign_price' => null, + 'status' => null, + 'errors' => null, + 'warnings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'quantum' => false, + 'available' => false, + 'basic_price' => false, + 'campaign_price' => false, + 'status' => false, + 'errors' => true, + 'warnings' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'quantum' => 'quantum', + 'available' => 'available', + 'basic_price' => 'basicPrice', + 'campaign_price' => 'campaignPrice', + 'status' => 'status', + 'errors' => 'errors', + 'warnings' => 'warnings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'quantum' => 'setQuantum', + 'available' => 'setAvailable', + 'basic_price' => 'setBasicPrice', + 'campaign_price' => 'setCampaignPrice', + 'status' => 'setStatus', + 'errors' => 'setErrors', + 'warnings' => 'setWarnings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'quantum' => 'getQuantum', + 'available' => 'getAvailable', + 'basic_price' => 'getBasicPrice', + 'campaign_price' => 'getCampaignPrice', + 'status' => 'getStatus', + 'errors' => 'getErrors', + 'warnings' => 'getWarnings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('quantum', $data ?? [], null); + $this->setIfExists('available', $data ?? [], null); + $this->setIfExists('basic_price', $data ?? [], null); + $this->setIfExists('campaign_price', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling GetCampaignOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling GetCampaignOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling GetCampaignOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets quantum + * + * @return \OpenAPI\Client\Model\QuantumDTO|null + */ + public function getQuantum() + { + return $this->container['quantum']; + } + + /** + * Sets quantum + * + * @param \OpenAPI\Client\Model\QuantumDTO|null $quantum quantum + * + * @return self + */ + public function setQuantum($quantum) + { + if (is_null($quantum)) { + throw new \InvalidArgumentException('non-nullable quantum cannot be null'); + } + $this->container['quantum'] = $quantum; + + return $this; + } + + /** + * Gets available + * + * @return bool|null + */ + public function getAvailable() + { + return $this->container['available']; + } + + /** + * Sets available + * + * @param bool|null $available Есть ли товар в продаже. + * + * @return self + */ + public function setAvailable($available) + { + if (is_null($available)) { + throw new \InvalidArgumentException('non-nullable available cannot be null'); + } + $this->container['available'] = $available; + + return $this; + } + + /** + * Gets basic_price + * + * @return \OpenAPI\Client\Model\GetPriceWithDiscountDTO|null + */ + public function getBasicPrice() + { + return $this->container['basic_price']; + } + + /** + * Sets basic_price + * + * @param \OpenAPI\Client\Model\GetPriceWithDiscountDTO|null $basic_price basic_price + * + * @return self + */ + public function setBasicPrice($basic_price) + { + if (is_null($basic_price)) { + throw new \InvalidArgumentException('non-nullable basic_price cannot be null'); + } + $this->container['basic_price'] = $basic_price; + + return $this; + } + + /** + * Gets campaign_price + * + * @return \OpenAPI\Client\Model\GetPriceWithVatDTO|null + */ + public function getCampaignPrice() + { + return $this->container['campaign_price']; + } + + /** + * Sets campaign_price + * + * @param \OpenAPI\Client\Model\GetPriceWithVatDTO|null $campaign_price campaign_price + * + * @return self + */ + public function setCampaignPrice($campaign_price) + { + if (is_null($campaign_price)) { + throw new \InvalidArgumentException('non-nullable campaign_price cannot be null'); + } + $this->container['campaign_price'] = $campaign_price; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OfferCampaignStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OfferCampaignStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\OfferErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\OfferErrorDTO[]|null $errors Ошибки, препятствующие размещению товара на витрине. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + + /** + * Gets warnings + * + * @return \OpenAPI\Client\Model\OfferErrorDTO[]|null + */ + public function getWarnings() + { + return $this->container['warnings']; + } + + /** + * Sets warnings + * + * @param \OpenAPI\Client\Model\OfferErrorDTO[]|null $warnings Предупреждения, не препятствующие размещению товара на витрине. + * + * @return self + */ + public function setWarnings($warnings) + { + if (is_null($warnings)) { + array_push($this->openAPINullablesSetToNull, 'warnings'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('warnings', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['warnings'] = $warnings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignOffersRequest.php b/erp24/lib/yandex_market_api/Model/GetCampaignOffersRequest.php new file mode 100644 index 00000000..884d2553 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignOffersRequest.php @@ -0,0 +1,589 @@ + + */ +class GetCampaignOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]', + 'statuses' => '\OpenAPI\Client\Model\OfferCampaignStatusType[]', + 'category_ids' => 'int[]', + 'vendor_names' => 'string[]', + 'tags' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null, + 'statuses' => null, + 'category_ids' => null, + 'vendor_names' => null, + 'tags' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => true, + 'statuses' => true, + 'category_ids' => true, + 'vendor_names' => true, + 'tags' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds', + 'statuses' => 'statuses', + 'category_ids' => 'categoryIds', + 'vendor_names' => 'vendorNames', + 'tags' => 'tags' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds', + 'statuses' => 'setStatuses', + 'category_ids' => 'setCategoryIds', + 'vendor_names' => 'setVendorNames', + 'tags' => 'setTags' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds', + 'statuses' => 'getStatuses', + 'category_ids' => 'getCategoryIds', + 'vendor_names' => 'getVendorNames', + 'tags' => 'getTags' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + $this->setIfExists('statuses', $data ?? [], null); + $this->setIfExists('category_ids', $data ?? [], null); + $this->setIfExists('vendor_names', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) > 200)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 200."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[]|null + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[]|null $offer_ids Идентификаторы товаров, информация о которых нужна. {% note warning \"Такой список возвращается только целиком\" %} Не используйте это поле одновременно с фильтрами по статусам карточек, категориям, брендам или тегам. Если вы хотите воспользоваться фильтрами, оставьте поле пустым. Если вы запрашиваете информацию по конкретным SKU, не заполняйте: * `page_token` * `limit` {% endnote %}   + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($offer_ids) && (count($offer_ids) > 200)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling GetCampaignOffersRequest., number of items must be less than or equal to 200.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + + /** + * Gets statuses + * + * @return \OpenAPI\Client\Model\OfferCampaignStatusType[]|null + */ + public function getStatuses() + { + return $this->container['statuses']; + } + + /** + * Sets statuses + * + * @param \OpenAPI\Client\Model\OfferCampaignStatusType[]|null $statuses Фильтр по статусам товаров. + * + * @return self + */ + public function setStatuses($statuses) + { + if (is_null($statuses)) { + array_push($this->openAPINullablesSetToNull, 'statuses'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('statuses', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['statuses'] = $statuses; + + return $this; + } + + /** + * Gets category_ids + * + * @return int[]|null + */ + public function getCategoryIds() + { + return $this->container['category_ids']; + } + + /** + * Sets category_ids + * + * @param int[]|null $category_ids Фильтр по категориям на Маркете. + * + * @return self + */ + public function setCategoryIds($category_ids) + { + if (is_null($category_ids)) { + array_push($this->openAPINullablesSetToNull, 'category_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('category_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['category_ids'] = $category_ids; + + return $this; + } + + /** + * Gets vendor_names + * + * @return string[]|null + */ + public function getVendorNames() + { + return $this->container['vendor_names']; + } + + /** + * Sets vendor_names + * + * @param string[]|null $vendor_names Фильтр по брендам. + * + * @return self + */ + public function setVendorNames($vendor_names) + { + if (is_null($vendor_names)) { + array_push($this->openAPINullablesSetToNull, 'vendor_names'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('vendor_names', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['vendor_names'] = $vendor_names; + + return $this; + } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Фильтр по тегам. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + array_push($this->openAPINullablesSetToNull, 'tags'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tags', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tags'] = $tags; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignOffersResponse.php b/erp24/lib/yandex_market_api/Model/GetCampaignOffersResponse.php new file mode 100644 index 00000000..797bfed0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignOffersResponse.php @@ -0,0 +1,444 @@ + + */ +class GetCampaignOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetCampaignOffersResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetCampaignOffersResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetCampaignOffersResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignOffersResultDTO.php b/erp24/lib/yandex_market_api/Model/GetCampaignOffersResultDTO.php new file mode 100644 index 00000000..c5ac4844 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignOffersResultDTO.php @@ -0,0 +1,447 @@ + + */ +class GetCampaignOffersResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignOffersResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'offers' => '\OpenAPI\Client\Model\GetCampaignOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\GetCampaignOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\GetCampaignOfferDTO[] $offers Страница списка товаров. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignRegionResponse.php b/erp24/lib/yandex_market_api/Model/GetCampaignRegionResponse.php new file mode 100644 index 00000000..43a8bf32 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignRegionResponse.php @@ -0,0 +1,410 @@ + + */ +class GetCampaignRegionResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignRegionResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'region' => '\OpenAPI\Client\Model\RegionDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'region' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'region' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'region' => 'region' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'region' => 'setRegion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'region' => 'getRegion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('region', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets region + * + * @return \OpenAPI\Client\Model\RegionDTO|null + */ + public function getRegion() + { + return $this->container['region']; + } + + /** + * Sets region + * + * @param \OpenAPI\Client\Model\RegionDTO|null $region region + * + * @return self + */ + public function setRegion($region) + { + if (is_null($region)) { + throw new \InvalidArgumentException('non-nullable region cannot be null'); + } + $this->container['region'] = $region; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignResponse.php b/erp24/lib/yandex_market_api/Model/GetCampaignResponse.php new file mode 100644 index 00000000..3cd27a38 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignResponse.php @@ -0,0 +1,410 @@ + + */ +class GetCampaignResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign' => '\OpenAPI\Client\Model\CampaignDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign' => 'campaign' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign' => 'setCampaign' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign' => 'getCampaign' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign + * + * @return \OpenAPI\Client\Model\CampaignDTO|null + */ + public function getCampaign() + { + return $this->container['campaign']; + } + + /** + * Sets campaign + * + * @param \OpenAPI\Client\Model\CampaignDTO|null $campaign campaign + * + * @return self + */ + public function setCampaign($campaign) + { + if (is_null($campaign)) { + throw new \InvalidArgumentException('non-nullable campaign cannot be null'); + } + $this->container['campaign'] = $campaign; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignSettingsResponse.php b/erp24/lib/yandex_market_api/Model/GetCampaignSettingsResponse.php new file mode 100644 index 00000000..0721e66c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignSettingsResponse.php @@ -0,0 +1,410 @@ + + */ +class GetCampaignSettingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignSettingsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'settings' => '\OpenAPI\Client\Model\CampaignSettingsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'settings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'settings' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'settings' => 'settings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'settings' => 'setSettings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'settings' => 'getSettings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('settings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets settings + * + * @return \OpenAPI\Client\Model\CampaignSettingsDTO|null + */ + public function getSettings() + { + return $this->container['settings']; + } + + /** + * Sets settings + * + * @param \OpenAPI\Client\Model\CampaignSettingsDTO|null $settings settings + * + * @return self + */ + public function setSettings($settings) + { + if (is_null($settings)) { + throw new \InvalidArgumentException('non-nullable settings cannot be null'); + } + $this->container['settings'] = $settings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCampaignsResponse.php b/erp24/lib/yandex_market_api/Model/GetCampaignsResponse.php new file mode 100644 index 00000000..ad7916a2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCampaignsResponse.php @@ -0,0 +1,447 @@ + + */ +class GetCampaignsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCampaignsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaigns' => '\OpenAPI\Client\Model\CampaignDTO[]', + 'pager' => '\OpenAPI\Client\Model\FlippingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaigns' => null, + 'pager' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaigns' => false, + 'pager' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaigns' => 'campaigns', + 'pager' => 'pager' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaigns' => 'setCampaigns', + 'pager' => 'setPager' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaigns' => 'getCampaigns', + 'pager' => 'getPager' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaigns', $data ?? [], null); + $this->setIfExists('pager', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaigns'] === null) { + $invalidProperties[] = "'campaigns' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaigns + * + * @return \OpenAPI\Client\Model\CampaignDTO[] + */ + public function getCampaigns() + { + return $this->container['campaigns']; + } + + /** + * Sets campaigns + * + * @param \OpenAPI\Client\Model\CampaignDTO[] $campaigns Список с информацией по каждому магазину. + * + * @return self + */ + public function setCampaigns($campaigns) + { + if (is_null($campaigns)) { + throw new \InvalidArgumentException('non-nullable campaigns cannot be null'); + } + $this->container['campaigns'] = $campaigns; + + return $this; + } + + /** + * Gets pager + * + * @return \OpenAPI\Client\Model\FlippingPagerDTO|null + */ + public function getPager() + { + return $this->container['pager']; + } + + /** + * Sets pager + * + * @param \OpenAPI\Client\Model\FlippingPagerDTO|null $pager pager + * + * @return self + */ + public function setPager($pager) + { + if (is_null($pager)) { + throw new \InvalidArgumentException('non-nullable pager cannot be null'); + } + $this->container['pager'] = $pager; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumDTO.php b/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumDTO.php new file mode 100644 index 00000000..0eaccc72 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumDTO.php @@ -0,0 +1,454 @@ + + */ +class GetCategoriesMaxSaleQuantumDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCategoriesMaxSaleQuantumDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'results' => '\OpenAPI\Client\Model\MaxSaleQuantumDTO[]', + 'errors' => '\OpenAPI\Client\Model\CategoryErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'results' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'results' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'results' => 'results', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'results' => 'setResults', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'results' => 'getResults', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('results', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['results'] === null) { + $invalidProperties[] = "'results' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets results + * + * @return \OpenAPI\Client\Model\MaxSaleQuantumDTO[] + */ + public function getResults() + { + return $this->container['results']; + } + + /** + * Sets results + * + * @param \OpenAPI\Client\Model\MaxSaleQuantumDTO[] $results Категории и лимит на установку кванта и минимального количества товаров. + * + * @return self + */ + public function setResults($results) + { + if (is_null($results)) { + throw new \InvalidArgumentException('non-nullable results cannot be null'); + } + $this->container['results'] = $results; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\CategoryErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\CategoryErrorDTO[]|null $errors Ошибки, которые появились из-за переданных категорий. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumRequest.php b/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumRequest.php new file mode 100644 index 00000000..98a9f651 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumRequest.php @@ -0,0 +1,428 @@ + + */ +class GetCategoriesMaxSaleQuantumRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCategoriesMaxSaleQuantumRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'market_category_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'market_category_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'market_category_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'market_category_ids' => 'marketCategoryIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'market_category_ids' => 'setMarketCategoryIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'market_category_ids' => 'getMarketCategoryIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('market_category_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['market_category_ids'] === null) { + $invalidProperties[] = "'market_category_ids' can't be null"; + } + if ((count($this->container['market_category_ids']) > 1500)) { + $invalidProperties[] = "invalid value for 'market_category_ids', number of items must be less than or equal to 1500."; + } + + if ((count($this->container['market_category_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'market_category_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets market_category_ids + * + * @return int[] + */ + public function getMarketCategoryIds() + { + return $this->container['market_category_ids']; + } + + /** + * Sets market_category_ids + * + * @param int[] $market_category_ids Идентификаторы листовых категории на Маркете — тех, у которых нет дочерних категорий. + * + * @return self + */ + public function setMarketCategoryIds($market_category_ids) + { + if (is_null($market_category_ids)) { + throw new \InvalidArgumentException('non-nullable market_category_ids cannot be null'); + } + + if ((count($market_category_ids) > 1500)) { + throw new \InvalidArgumentException('invalid value for $market_category_ids when calling GetCategoriesMaxSaleQuantumRequest., number of items must be less than or equal to 1500.'); + } + if ((count($market_category_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $market_category_ids when calling GetCategoriesMaxSaleQuantumRequest., number of items must be greater than or equal to 1.'); + } + $this->container['market_category_ids'] = $market_category_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumResponse.php b/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumResponse.php new file mode 100644 index 00000000..37d17134 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCategoriesMaxSaleQuantumResponse.php @@ -0,0 +1,487 @@ + + */ +class GetCategoriesMaxSaleQuantumResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCategoriesMaxSaleQuantumResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'results' => '\OpenAPI\Client\Model\MaxSaleQuantumDTO[]', + 'errors' => '\OpenAPI\Client\Model\CategoryErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'results' => null, + 'errors' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'results' => false, + 'errors' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'results' => 'results', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'results' => 'setResults', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'results' => 'getResults', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('results', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['results'] === null) { + $invalidProperties[] = "'results' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets results + * + * @return \OpenAPI\Client\Model\MaxSaleQuantumDTO[] + */ + public function getResults() + { + return $this->container['results']; + } + + /** + * Sets results + * + * @param \OpenAPI\Client\Model\MaxSaleQuantumDTO[] $results Категории и лимит на установку кванта и минимального количества товаров. + * + * @return self + */ + public function setResults($results) + { + if (is_null($results)) { + throw new \InvalidArgumentException('non-nullable results cannot be null'); + } + $this->container['results'] = $results; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\CategoryErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\CategoryErrorDTO[]|null $errors Ошибки, которые появились из-за переданных категорий. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCategoriesRequest.php b/erp24/lib/yandex_market_api/Model/GetCategoriesRequest.php new file mode 100644 index 00000000..b5cb125a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCategoriesRequest.php @@ -0,0 +1,410 @@ + + */ +class GetCategoriesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCategoriesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'language' => '\OpenAPI\Client\Model\LanguageType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'language' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'language' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'language' => 'language' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'language' => 'setLanguage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'language' => 'getLanguage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('language', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets language + * + * @return \OpenAPI\Client\Model\LanguageType|null + */ + public function getLanguage() + { + return $this->container['language']; + } + + /** + * Sets language + * + * @param \OpenAPI\Client\Model\LanguageType|null $language language + * + * @return self + */ + public function setLanguage($language) + { + if (is_null($language)) { + throw new \InvalidArgumentException('non-nullable language cannot be null'); + } + $this->container['language'] = $language; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCategoriesResponse.php b/erp24/lib/yandex_market_api/Model/GetCategoriesResponse.php new file mode 100644 index 00000000..faefdcd3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCategoriesResponse.php @@ -0,0 +1,443 @@ + + */ +class GetCategoriesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCategoriesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\CategoryDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\CategoryDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\CategoryDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetCategoryContentParametersResponse.php b/erp24/lib/yandex_market_api/Model/GetCategoryContentParametersResponse.php new file mode 100644 index 00000000..42d95386 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetCategoryContentParametersResponse.php @@ -0,0 +1,444 @@ + + */ +class GetCategoryContentParametersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetCategoryContentParametersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\CategoryContentParametersDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\CategoryContentParametersDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\CategoryContentParametersDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetChatHistoryRequest.php b/erp24/lib/yandex_market_api/Model/GetChatHistoryRequest.php new file mode 100644 index 00000000..96182476 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetChatHistoryRequest.php @@ -0,0 +1,419 @@ + + */ +class GetChatHistoryRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetChatHistoryRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'message_id_from' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'message_id_from' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'message_id_from' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message_id_from' => 'messageIdFrom' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message_id_from' => 'setMessageIdFrom' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message_id_from' => 'getMessageIdFrom' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('message_id_from', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['message_id_from']) && ($this->container['message_id_from'] < 1)) { + $invalidProperties[] = "invalid value for 'message_id_from', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message_id_from + * + * @return int|null + */ + public function getMessageIdFrom() + { + return $this->container['message_id_from']; + } + + /** + * Sets message_id_from + * + * @param int|null $message_id_from Идентификатор сообщения, начиная с которого нужно получить все последующие сообщения. + * + * @return self + */ + public function setMessageIdFrom($message_id_from) + { + if (is_null($message_id_from)) { + throw new \InvalidArgumentException('non-nullable message_id_from cannot be null'); + } + + if (($message_id_from < 1)) { + throw new \InvalidArgumentException('invalid value for $message_id_from when calling GetChatHistoryRequest., must be bigger than or equal to 1.'); + } + + $this->container['message_id_from'] = $message_id_from; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetChatHistoryResponse.php b/erp24/lib/yandex_market_api/Model/GetChatHistoryResponse.php new file mode 100644 index 00000000..f484bd01 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetChatHistoryResponse.php @@ -0,0 +1,443 @@ + + */ +class GetChatHistoryResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetChatHistoryResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\ChatMessagesResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\ChatMessagesResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\ChatMessagesResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetChatInfoDTO.php b/erp24/lib/yandex_market_api/Model/GetChatInfoDTO.php new file mode 100644 index 00000000..ef7b191c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetChatInfoDTO.php @@ -0,0 +1,607 @@ + + */ +class GetChatInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetChatInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'chat_id' => 'int', + 'order_id' => 'int', + 'type' => '\OpenAPI\Client\Model\ChatType', + 'status' => '\OpenAPI\Client\Model\ChatStatusType', + 'created_at' => '\DateTime', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'chat_id' => 'int64', + 'order_id' => 'int64', + 'type' => null, + 'status' => null, + 'created_at' => 'date-time', + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'chat_id' => false, + 'order_id' => false, + 'type' => false, + 'status' => false, + 'created_at' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'chat_id' => 'chatId', + 'order_id' => 'orderId', + 'type' => 'type', + 'status' => 'status', + 'created_at' => 'createdAt', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'chat_id' => 'setChatId', + 'order_id' => 'setOrderId', + 'type' => 'setType', + 'status' => 'setStatus', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'chat_id' => 'getChatId', + 'order_id' => 'getOrderId', + 'type' => 'getType', + 'status' => 'getStatus', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('chat_id', $data ?? [], null); + $this->setIfExists('order_id', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['chat_id'] === null) { + $invalidProperties[] = "'chat_id' can't be null"; + } + if (($this->container['chat_id'] < 1)) { + $invalidProperties[] = "invalid value for 'chat_id', must be bigger than or equal to 1."; + } + + if ($this->container['order_id'] === null) { + $invalidProperties[] = "'order_id' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + if ($this->container['created_at'] === null) { + $invalidProperties[] = "'created_at' can't be null"; + } + if ($this->container['updated_at'] === null) { + $invalidProperties[] = "'updated_at' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets chat_id + * + * @return int + */ + public function getChatId() + { + return $this->container['chat_id']; + } + + /** + * Sets chat_id + * + * @param int $chat_id Идентификатор чата. + * + * @return self + */ + public function setChatId($chat_id) + { + if (is_null($chat_id)) { + throw new \InvalidArgumentException('non-nullable chat_id cannot be null'); + } + + if (($chat_id < 1)) { + throw new \InvalidArgumentException('invalid value for $chat_id when calling GetChatInfoDTO., must be bigger than or equal to 1.'); + } + + $this->container['chat_id'] = $chat_id; + + return $this; + } + + /** + * Gets order_id + * + * @return int + */ + public function getOrderId() + { + return $this->container['order_id']; + } + + /** + * Sets order_id + * + * @param int $order_id Идентификатор заказа. + * + * @return self + */ + public function setOrderId($order_id) + { + if (is_null($order_id)) { + throw new \InvalidArgumentException('non-nullable order_id cannot be null'); + } + $this->container['order_id'] = $order_id; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\ChatType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\ChatType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ChatStatusType + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ChatStatusType $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime $created_at Дата и время создания чата. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setCreatedAt($created_at) + { + if (is_null($created_at)) { + throw new \InvalidArgumentException('non-nullable created_at cannot be null'); + } + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime $updated_at Дата и время последнего сообщения в чате. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetChatsInfoDTO.php b/erp24/lib/yandex_market_api/Model/GetChatsInfoDTO.php new file mode 100644 index 00000000..424395ee --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetChatsInfoDTO.php @@ -0,0 +1,447 @@ + + */ +class GetChatsInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetChatsInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'chats' => '\OpenAPI\Client\Model\GetChatInfoDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'chats' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'chats' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'chats' => 'chats', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'chats' => 'setChats', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'chats' => 'getChats', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('chats', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['chats'] === null) { + $invalidProperties[] = "'chats' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets chats + * + * @return \OpenAPI\Client\Model\GetChatInfoDTO[] + */ + public function getChats() + { + return $this->container['chats']; + } + + /** + * Sets chats + * + * @param \OpenAPI\Client\Model\GetChatInfoDTO[] $chats Информация о чатах. + * + * @return self + */ + public function setChats($chats) + { + if (is_null($chats)) { + throw new \InvalidArgumentException('non-nullable chats cannot be null'); + } + $this->container['chats'] = $chats; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetChatsRequest.php b/erp24/lib/yandex_market_api/Model/GetChatsRequest.php new file mode 100644 index 00000000..23a4c5e1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetChatsRequest.php @@ -0,0 +1,526 @@ + + */ +class GetChatsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetChatsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order_ids' => 'int[]', + 'types' => '\OpenAPI\Client\Model\ChatType[]', + 'statuses' => '\OpenAPI\Client\Model\ChatStatusType[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order_ids' => 'int64', + 'types' => null, + 'statuses' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order_ids' => true, + 'types' => true, + 'statuses' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order_ids' => 'orderIds', + 'types' => 'types', + 'statuses' => 'statuses' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order_ids' => 'setOrderIds', + 'types' => 'setTypes', + 'statuses' => 'setStatuses' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order_ids' => 'getOrderIds', + 'types' => 'getTypes', + 'statuses' => 'getStatuses' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order_ids', $data ?? [], null); + $this->setIfExists('types', $data ?? [], null); + $this->setIfExists('statuses', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['order_ids']) && (count($this->container['order_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'order_ids', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['types']) && (count($this->container['types']) < 1)) { + $invalidProperties[] = "invalid value for 'types', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['statuses']) && (count($this->container['statuses']) < 1)) { + $invalidProperties[] = "invalid value for 'statuses', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order_ids + * + * @return int[]|null + */ + public function getOrderIds() + { + return $this->container['order_ids']; + } + + /** + * Sets order_ids + * + * @param int[]|null $order_ids Фильтр по идентификаторам заказов на Маркете. + * + * @return self + */ + public function setOrderIds($order_ids) + { + if (is_null($order_ids)) { + array_push($this->openAPINullablesSetToNull, 'order_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($order_ids) && (count($order_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $order_ids when calling GetChatsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['order_ids'] = $order_ids; + + return $this; + } + + /** + * Gets types + * + * @return \OpenAPI\Client\Model\ChatType[]|null + */ + public function getTypes() + { + return $this->container['types']; + } + + /** + * Sets types + * + * @param \OpenAPI\Client\Model\ChatType[]|null $types Фильтр по типам чатов. + * + * @return self + */ + public function setTypes($types) + { + if (is_null($types)) { + array_push($this->openAPINullablesSetToNull, 'types'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('types', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($types) && (count($types) < 1)) { + throw new \InvalidArgumentException('invalid length for $types when calling GetChatsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['types'] = $types; + + return $this; + } + + /** + * Gets statuses + * + * @return \OpenAPI\Client\Model\ChatStatusType[]|null + */ + public function getStatuses() + { + return $this->container['statuses']; + } + + /** + * Sets statuses + * + * @param \OpenAPI\Client\Model\ChatStatusType[]|null $statuses Фильтр по статусам чатов. + * + * @return self + */ + public function setStatuses($statuses) + { + if (is_null($statuses)) { + array_push($this->openAPINullablesSetToNull, 'statuses'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('statuses', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($statuses) && (count($statuses) < 1)) { + throw new \InvalidArgumentException('invalid length for $statuses when calling GetChatsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['statuses'] = $statuses; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetChatsResponse.php b/erp24/lib/yandex_market_api/Model/GetChatsResponse.php new file mode 100644 index 00000000..b88ad54c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetChatsResponse.php @@ -0,0 +1,443 @@ + + */ +class GetChatsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetChatsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetChatsInfoDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetChatsInfoDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetChatsInfoDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetDeliveryServicesResponse.php b/erp24/lib/yandex_market_api/Model/GetDeliveryServicesResponse.php new file mode 100644 index 00000000..7d53f19d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetDeliveryServicesResponse.php @@ -0,0 +1,410 @@ + + */ +class GetDeliveryServicesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetDeliveryServicesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'result' => '\OpenAPI\Client\Model\DeliveryServicesDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\DeliveryServicesDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\DeliveryServicesDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetFeedIndexLogsResponse.php b/erp24/lib/yandex_market_api/Model/GetFeedIndexLogsResponse.php new file mode 100644 index 00000000..dcc34532 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetFeedIndexLogsResponse.php @@ -0,0 +1,443 @@ + + */ +class GetFeedIndexLogsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetFeedIndexLogsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\FeedIndexLogsResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\FeedIndexLogsResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\FeedIndexLogsResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetFeedResponse.php b/erp24/lib/yandex_market_api/Model/GetFeedResponse.php new file mode 100644 index 00000000..04517235 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetFeedResponse.php @@ -0,0 +1,410 @@ + + */ +class GetFeedResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetFeedResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feed' => '\OpenAPI\Client\Model\FeedDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feed' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feed' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'feed' => 'feed' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feed' => 'setFeed' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feed' => 'getFeed' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('feed', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets feed + * + * @return \OpenAPI\Client\Model\FeedDTO|null + */ + public function getFeed() + { + return $this->container['feed']; + } + + /** + * Sets feed + * + * @param \OpenAPI\Client\Model\FeedDTO|null $feed feed + * + * @return self + */ + public function setFeed($feed) + { + if (is_null($feed)) { + throw new \InvalidArgumentException('non-nullable feed cannot be null'); + } + $this->container['feed'] = $feed; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetFeedbackListResponse.php b/erp24/lib/yandex_market_api/Model/GetFeedbackListResponse.php new file mode 100644 index 00000000..36dc3a40 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetFeedbackListResponse.php @@ -0,0 +1,443 @@ + + */ +class GetFeedbackListResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetFeedbackListResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\FeedbackListDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\FeedbackListDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\FeedbackListDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetFeedsResponse.php b/erp24/lib/yandex_market_api/Model/GetFeedsResponse.php new file mode 100644 index 00000000..b3f59bc0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetFeedsResponse.php @@ -0,0 +1,413 @@ + + */ +class GetFeedsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetFeedsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feeds' => '\OpenAPI\Client\Model\FeedDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feeds' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feeds' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'feeds' => 'feeds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feeds' => 'setFeeds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feeds' => 'getFeeds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('feeds', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['feeds'] === null) { + $invalidProperties[] = "'feeds' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets feeds + * + * @return \OpenAPI\Client\Model\FeedDTO[] + */ + public function getFeeds() + { + return $this->container['feeds']; + } + + /** + * Sets feeds + * + * @param \OpenAPI\Client\Model\FeedDTO[] $feeds Список прайс-листов. + * + * @return self + */ + public function setFeeds($feeds) + { + if (is_null($feeds)) { + throw new \InvalidArgumentException('non-nullable feeds cannot be null'); + } + $this->container['feeds'] = $feeds; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetFulfillmentWarehousesResponse.php b/erp24/lib/yandex_market_api/Model/GetFulfillmentWarehousesResponse.php new file mode 100644 index 00000000..7647324f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetFulfillmentWarehousesResponse.php @@ -0,0 +1,443 @@ + + */ +class GetFulfillmentWarehousesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetFulfillmentWarehousesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\FulfillmentWarehousesDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\FulfillmentWarehousesDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\FulfillmentWarehousesDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackCommentsRequest.php b/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackCommentsRequest.php new file mode 100644 index 00000000..7026a53e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackCommentsRequest.php @@ -0,0 +1,413 @@ + + */ +class GetGoodsFeedbackCommentsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetGoodsFeedbackCommentsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feedback_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feedback_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feedback_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'feedback_id' => 'feedbackId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feedback_id' => 'setFeedbackId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feedback_id' => 'getFeedbackId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('feedback_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['feedback_id'] === null) { + $invalidProperties[] = "'feedback_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets feedback_id + * + * @return int + */ + public function getFeedbackId() + { + return $this->container['feedback_id']; + } + + /** + * Sets feedback_id + * + * @param int $feedback_id Идентификатор отзыва. + * + * @return self + */ + public function setFeedbackId($feedback_id) + { + if (is_null($feedback_id)) { + throw new \InvalidArgumentException('non-nullable feedback_id cannot be null'); + } + $this->container['feedback_id'] = $feedback_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackCommentsResponse.php b/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackCommentsResponse.php new file mode 100644 index 00000000..a8850b99 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackCommentsResponse.php @@ -0,0 +1,443 @@ + + */ +class GetGoodsFeedbackCommentsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetGoodsFeedbackCommentsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GoodsFeedbackCommentListDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GoodsFeedbackCommentListDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GoodsFeedbackCommentListDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackRequest.php b/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackRequest.php new file mode 100644 index 00000000..7e027997 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackRequest.php @@ -0,0 +1,610 @@ + + */ +class GetGoodsFeedbackRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetGoodsFeedbackRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'date_time_from' => '\DateTime', + 'date_time_to' => '\DateTime', + 'reaction_status' => '\OpenAPI\Client\Model\FeedbackReactionStatusType', + 'rating_values' => 'int[]', + 'model_ids' => 'int[]', + 'paid' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'date_time_from' => 'date-time', + 'date_time_to' => 'date-time', + 'reaction_status' => null, + 'rating_values' => 'int32', + 'model_ids' => 'int64', + 'paid' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'date_time_from' => false, + 'date_time_to' => false, + 'reaction_status' => false, + 'rating_values' => true, + 'model_ids' => true, + 'paid' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'date_time_from' => 'dateTimeFrom', + 'date_time_to' => 'dateTimeTo', + 'reaction_status' => 'reactionStatus', + 'rating_values' => 'ratingValues', + 'model_ids' => 'modelIds', + 'paid' => 'paid' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'date_time_from' => 'setDateTimeFrom', + 'date_time_to' => 'setDateTimeTo', + 'reaction_status' => 'setReactionStatus', + 'rating_values' => 'setRatingValues', + 'model_ids' => 'setModelIds', + 'paid' => 'setPaid' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'date_time_from' => 'getDateTimeFrom', + 'date_time_to' => 'getDateTimeTo', + 'reaction_status' => 'getReactionStatus', + 'rating_values' => 'getRatingValues', + 'model_ids' => 'getModelIds', + 'paid' => 'getPaid' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('date_time_from', $data ?? [], null); + $this->setIfExists('date_time_to', $data ?? [], null); + $this->setIfExists('reaction_status', $data ?? [], null); + $this->setIfExists('rating_values', $data ?? [], null); + $this->setIfExists('model_ids', $data ?? [], null); + $this->setIfExists('paid', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['rating_values']) && (count($this->container['rating_values']) > 5)) { + $invalidProperties[] = "invalid value for 'rating_values', number of items must be less than or equal to 5."; + } + + if (!is_null($this->container['model_ids']) && (count($this->container['model_ids']) > 20)) { + $invalidProperties[] = "invalid value for 'model_ids', number of items must be less than or equal to 20."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets date_time_from + * + * @return \DateTime|null + */ + public function getDateTimeFrom() + { + return $this->container['date_time_from']; + } + + /** + * Sets date_time_from + * + * @param \DateTime|null $date_time_from Начало периода. Не включительно. Если параметр не указан, возвращается информация за 6 месяцев до указанной в `dateTimeTo` даты. + * + * @return self + */ + public function setDateTimeFrom($date_time_from) + { + if (is_null($date_time_from)) { + throw new \InvalidArgumentException('non-nullable date_time_from cannot be null'); + } + $this->container['date_time_from'] = $date_time_from; + + return $this; + } + + /** + * Gets date_time_to + * + * @return \DateTime|null + */ + public function getDateTimeTo() + { + return $this->container['date_time_to']; + } + + /** + * Sets date_time_to + * + * @param \DateTime|null $date_time_to Конец периода. Не включительно. Если параметр не указан, используется текущая дата. + * + * @return self + */ + public function setDateTimeTo($date_time_to) + { + if (is_null($date_time_to)) { + throw new \InvalidArgumentException('non-nullable date_time_to cannot be null'); + } + $this->container['date_time_to'] = $date_time_to; + + return $this; + } + + /** + * Gets reaction_status + * + * @return \OpenAPI\Client\Model\FeedbackReactionStatusType|null + */ + public function getReactionStatus() + { + return $this->container['reaction_status']; + } + + /** + * Sets reaction_status + * + * @param \OpenAPI\Client\Model\FeedbackReactionStatusType|null $reaction_status reaction_status + * + * @return self + */ + public function setReactionStatus($reaction_status) + { + if (is_null($reaction_status)) { + throw new \InvalidArgumentException('non-nullable reaction_status cannot be null'); + } + $this->container['reaction_status'] = $reaction_status; + + return $this; + } + + /** + * Gets rating_values + * + * @return int[]|null + */ + public function getRatingValues() + { + return $this->container['rating_values']; + } + + /** + * Sets rating_values + * + * @param int[]|null $rating_values Оценка товара. + * + * @return self + */ + public function setRatingValues($rating_values) + { + if (is_null($rating_values)) { + array_push($this->openAPINullablesSetToNull, 'rating_values'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('rating_values', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($rating_values) && (count($rating_values) > 5)) { + throw new \InvalidArgumentException('invalid value for $rating_values when calling GetGoodsFeedbackRequest., number of items must be less than or equal to 5.'); + } + $this->container['rating_values'] = $rating_values; + + return $this; + } + + /** + * Gets model_ids + * + * @return int[]|null + */ + public function getModelIds() + { + return $this->container['model_ids']; + } + + /** + * Sets model_ids + * + * @param int[]|null $model_ids Фильтр по идентификатору модели товара. Получить идентификатор модели можно с помощью одного из запросов: * [POST businesses/{businessId}/offer-mappings](../../reference/business-assortment/getOfferMappings.md); * [POST businesses/{businessId}/offer-cards](../../reference/content/getOfferCardsContentStatus.md); * [POST models](../../reference/models/getModels.md). + * + * @return self + */ + public function setModelIds($model_ids) + { + if (is_null($model_ids)) { + array_push($this->openAPINullablesSetToNull, 'model_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('model_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($model_ids) && (count($model_ids) > 20)) { + throw new \InvalidArgumentException('invalid value for $model_ids when calling GetGoodsFeedbackRequest., number of items must be less than or equal to 20.'); + } + $this->container['model_ids'] = $model_ids; + + return $this; + } + + /** + * Gets paid + * + * @return bool|null + */ + public function getPaid() + { + return $this->container['paid']; + } + + /** + * Sets paid + * + * @param bool|null $paid Фильтр отзывов за баллы Плюса. + * + * @return self + */ + public function setPaid($paid) + { + if (is_null($paid)) { + throw new \InvalidArgumentException('non-nullable paid cannot be null'); + } + $this->container['paid'] = $paid; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackResponse.php b/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackResponse.php new file mode 100644 index 00000000..937a1993 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetGoodsFeedbackResponse.php @@ -0,0 +1,443 @@ + + */ +class GetGoodsFeedbackResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetGoodsFeedbackResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GoodsFeedbackListDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GoodsFeedbackListDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GoodsFeedbackListDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetGoodsStatsRequest.php b/erp24/lib/yandex_market_api/Model/GetGoodsStatsRequest.php new file mode 100644 index 00000000..1b86e60b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetGoodsStatsRequest.php @@ -0,0 +1,428 @@ + + */ +class GetGoodsStatsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetGoodsStatsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'shop_skus' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'shop_skus' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'shop_skus' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'shop_skus' => 'shopSkus' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'shop_skus' => 'setShopSkus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'shop_skus' => 'getShopSkus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('shop_skus', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['shop_skus'] === null) { + $invalidProperties[] = "'shop_skus' can't be null"; + } + if ((count($this->container['shop_skus']) > 500)) { + $invalidProperties[] = "invalid value for 'shop_skus', number of items must be less than or equal to 500."; + } + + if ((count($this->container['shop_skus']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_skus', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets shop_skus + * + * @return string[] + */ + public function getShopSkus() + { + return $this->container['shop_skus']; + } + + /** + * Sets shop_skus + * + * @param string[] $shop_skus Список ваших идентификаторов SKU. + * + * @return self + */ + public function setShopSkus($shop_skus) + { + if (is_null($shop_skus)) { + throw new \InvalidArgumentException('non-nullable shop_skus cannot be null'); + } + + if ((count($shop_skus) > 500)) { + throw new \InvalidArgumentException('invalid value for $shop_skus when calling GetGoodsStatsRequest., number of items must be less than or equal to 500.'); + } + if ((count($shop_skus) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_skus when calling GetGoodsStatsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['shop_skus'] = $shop_skus; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetGoodsStatsResponse.php b/erp24/lib/yandex_market_api/Model/GetGoodsStatsResponse.php new file mode 100644 index 00000000..342ec8d2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetGoodsStatsResponse.php @@ -0,0 +1,444 @@ + + */ +class GetGoodsStatsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetGoodsStatsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GoodsStatsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GoodsStatsDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GoodsStatsDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetHiddenOffersResponse.php b/erp24/lib/yandex_market_api/Model/GetHiddenOffersResponse.php new file mode 100644 index 00000000..af74a887 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetHiddenOffersResponse.php @@ -0,0 +1,444 @@ + + */ +class GetHiddenOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetHiddenOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetHiddenOffersResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetHiddenOffersResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetHiddenOffersResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetHiddenOffersResultDTO.php b/erp24/lib/yandex_market_api/Model/GetHiddenOffersResultDTO.php new file mode 100644 index 00000000..0429e023 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetHiddenOffersResultDTO.php @@ -0,0 +1,447 @@ + + */ +class GetHiddenOffersResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetHiddenOffersResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'hidden_offers' => '\OpenAPI\Client\Model\HiddenOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'hidden_offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'hidden_offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'hidden_offers' => 'hiddenOffers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'hidden_offers' => 'setHiddenOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'hidden_offers' => 'getHiddenOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('hidden_offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['hidden_offers'] === null) { + $invalidProperties[] = "'hidden_offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets hidden_offers + * + * @return \OpenAPI\Client\Model\HiddenOfferDTO[] + */ + public function getHiddenOffers() + { + return $this->container['hidden_offers']; + } + + /** + * Sets hidden_offers + * + * @param \OpenAPI\Client\Model\HiddenOfferDTO[] $hidden_offers Список скрытых товаров. + * + * @return self + */ + public function setHiddenOffers($hidden_offers) + { + if (is_null($hidden_offers)) { + throw new \InvalidArgumentException('non-nullable hidden_offers cannot be null'); + } + $this->container['hidden_offers'] = $hidden_offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetMappingDTO.php b/erp24/lib/yandex_market_api/Model/GetMappingDTO.php new file mode 100644 index 00000000..cd188af0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetMappingDTO.php @@ -0,0 +1,589 @@ + + */ +class GetMappingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetMappingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'market_sku' => 'int', + 'market_sku_name' => 'string', + 'market_model_id' => 'int', + 'market_model_name' => 'string', + 'market_category_id' => 'int', + 'market_category_name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'market_sku' => 'int64', + 'market_sku_name' => null, + 'market_model_id' => 'int64', + 'market_model_name' => null, + 'market_category_id' => 'int64', + 'market_category_name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'market_sku' => false, + 'market_sku_name' => false, + 'market_model_id' => false, + 'market_model_name' => false, + 'market_category_id' => false, + 'market_category_name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'market_sku' => 'marketSku', + 'market_sku_name' => 'marketSkuName', + 'market_model_id' => 'marketModelId', + 'market_model_name' => 'marketModelName', + 'market_category_id' => 'marketCategoryId', + 'market_category_name' => 'marketCategoryName' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'market_sku' => 'setMarketSku', + 'market_sku_name' => 'setMarketSkuName', + 'market_model_id' => 'setMarketModelId', + 'market_model_name' => 'setMarketModelName', + 'market_category_id' => 'setMarketCategoryId', + 'market_category_name' => 'setMarketCategoryName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'market_sku' => 'getMarketSku', + 'market_sku_name' => 'getMarketSkuName', + 'market_model_id' => 'getMarketModelId', + 'market_model_name' => 'getMarketModelName', + 'market_category_id' => 'getMarketCategoryId', + 'market_category_name' => 'getMarketCategoryName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('market_sku', $data ?? [], null); + $this->setIfExists('market_sku_name', $data ?? [], null); + $this->setIfExists('market_model_id', $data ?? [], null); + $this->setIfExists('market_model_name', $data ?? [], null); + $this->setIfExists('market_category_id', $data ?? [], null); + $this->setIfExists('market_category_name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling GetMappingDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + + /** + * Gets market_sku_name + * + * @return string|null + */ + public function getMarketSkuName() + { + return $this->container['market_sku_name']; + } + + /** + * Sets market_sku_name + * + * @param string|null $market_sku_name Название карточки товара. Может отсутствовать в ответе, если товар еще не привязан к карточке. + * + * @return self + */ + public function setMarketSkuName($market_sku_name) + { + if (is_null($market_sku_name)) { + throw new \InvalidArgumentException('non-nullable market_sku_name cannot be null'); + } + $this->container['market_sku_name'] = $market_sku_name; + + return $this; + } + + /** + * Gets market_model_id + * + * @return int|null + */ + public function getMarketModelId() + { + return $this->container['market_model_id']; + } + + /** + * Sets market_model_id + * + * @param int|null $market_model_id Идентификатор модели на Маркете. Может отсутствовать в ответе, если товар еще не привязан к карточке. + * + * @return self + */ + public function setMarketModelId($market_model_id) + { + if (is_null($market_model_id)) { + throw new \InvalidArgumentException('non-nullable market_model_id cannot be null'); + } + $this->container['market_model_id'] = $market_model_id; + + return $this; + } + + /** + * Gets market_model_name + * + * @return string|null + */ + public function getMarketModelName() + { + return $this->container['market_model_name']; + } + + /** + * Sets market_model_name + * + * @param string|null $market_model_name Название модели на Маркете. Может отсутствовать в ответе, если товар еще не привязан к карточке. + * + * @return self + */ + public function setMarketModelName($market_model_name) + { + if (is_null($market_model_name)) { + throw new \InvalidArgumentException('non-nullable market_model_name cannot be null'); + } + $this->container['market_model_name'] = $market_model_name; + + return $this; + } + + /** + * Gets market_category_id + * + * @return int|null + */ + public function getMarketCategoryId() + { + return $this->container['market_category_id']; + } + + /** + * Sets market_category_id + * + * @param int|null $market_category_id Идентификатор категории на Маркете, в которую попал товар. Может отсутствовать в ответе, если Маркет еще не определил категорию товара. + * + * @return self + */ + public function setMarketCategoryId($market_category_id) + { + if (is_null($market_category_id)) { + throw new \InvalidArgumentException('non-nullable market_category_id cannot be null'); + } + $this->container['market_category_id'] = $market_category_id; + + return $this; + } + + /** + * Gets market_category_name + * + * @return string|null + */ + public function getMarketCategoryName() + { + return $this->container['market_category_name']; + } + + /** + * Sets market_category_name + * + * @param string|null $market_category_name Название категории карточки на Маркете. Может отсутствовать в ответе, если Маркет еще не определил категорию товара. + * + * @return self + */ + public function setMarketCategoryName($market_category_name) + { + if (is_null($market_category_name)) { + throw new \InvalidArgumentException('non-nullable market_category_name cannot be null'); + } + $this->container['market_category_name'] = $market_category_name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetModelsOffersResponse.php b/erp24/lib/yandex_market_api/Model/GetModelsOffersResponse.php new file mode 100644 index 00000000..b5bdee11 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetModelsOffersResponse.php @@ -0,0 +1,481 @@ + + */ +class GetModelsOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetModelsOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'models' => '\OpenAPI\Client\Model\EnrichedModelDTO[]', + 'currency' => '\OpenAPI\Client\Model\CurrencyType', + 'region_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'models' => null, + 'currency' => null, + 'region_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'models' => false, + 'currency' => false, + 'region_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'models' => 'models', + 'currency' => 'currency', + 'region_id' => 'regionId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'models' => 'setModels', + 'currency' => 'setCurrency', + 'region_id' => 'setRegionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'models' => 'getModels', + 'currency' => 'getCurrency', + 'region_id' => 'getRegionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('models', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('region_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['models'] === null) { + $invalidProperties[] = "'models' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets models + * + * @return \OpenAPI\Client\Model\EnrichedModelDTO[] + */ + public function getModels() + { + return $this->container['models']; + } + + /** + * Sets models + * + * @param \OpenAPI\Client\Model\EnrichedModelDTO[] $models Список моделей товаров. + * + * @return self + */ + public function setModels($models) + { + if (is_null($models)) { + throw new \InvalidArgumentException('non-nullable models cannot be null'); + } + $this->container['models'] = $models; + + return $this; + } + + /** + * Gets currency + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets region_id + * + * @return int|null + */ + public function getRegionId() + { + return $this->container['region_id']; + } + + /** + * Sets region_id + * + * @param int|null $region_id Идентификатор региона, для которого выводится информация о предложениях модели (доставляемых в этот регион). Информацию о регионе по идентификатору можно получить с помощью запроса [GET regions/{regionId}](../../reference/regions/searchRegionsById.md). + * + * @return self + */ + public function setRegionId($region_id) + { + if (is_null($region_id)) { + throw new \InvalidArgumentException('non-nullable region_id cannot be null'); + } + $this->container['region_id'] = $region_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetModelsRequest.php b/erp24/lib/yandex_market_api/Model/GetModelsRequest.php new file mode 100644 index 00000000..b17026d7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetModelsRequest.php @@ -0,0 +1,422 @@ + + */ +class GetModelsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetModelsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'models' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'models' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'models' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'models' => 'models' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'models' => 'setModels' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'models' => 'getModels' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('models', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['models'] === null) { + $invalidProperties[] = "'models' can't be null"; + } + if ((count($this->container['models']) < 1)) { + $invalidProperties[] = "invalid value for 'models', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets models + * + * @return int[] + */ + public function getModels() + { + return $this->container['models']; + } + + /** + * Sets models + * + * @param int[] $models Список моделей. + * + * @return self + */ + public function setModels($models) + { + if (is_null($models)) { + throw new \InvalidArgumentException('non-nullable models cannot be null'); + } + + + if ((count($models) < 1)) { + throw new \InvalidArgumentException('invalid length for $models when calling GetModelsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['models'] = $models; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetModelsResponse.php b/erp24/lib/yandex_market_api/Model/GetModelsResponse.php new file mode 100644 index 00000000..bcdb1ca2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetModelsResponse.php @@ -0,0 +1,481 @@ + + */ +class GetModelsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetModelsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'models' => '\OpenAPI\Client\Model\ModelDTO[]', + 'currency' => '\OpenAPI\Client\Model\CurrencyType', + 'region_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'models' => null, + 'currency' => null, + 'region_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'models' => false, + 'currency' => false, + 'region_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'models' => 'models', + 'currency' => 'currency', + 'region_id' => 'regionId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'models' => 'setModels', + 'currency' => 'setCurrency', + 'region_id' => 'setRegionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'models' => 'getModels', + 'currency' => 'getCurrency', + 'region_id' => 'getRegionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('models', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('region_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['models'] === null) { + $invalidProperties[] = "'models' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets models + * + * @return \OpenAPI\Client\Model\ModelDTO[] + */ + public function getModels() + { + return $this->container['models']; + } + + /** + * Sets models + * + * @param \OpenAPI\Client\Model\ModelDTO[] $models Список моделей товаров. + * + * @return self + */ + public function setModels($models) + { + if (is_null($models)) { + throw new \InvalidArgumentException('non-nullable models cannot be null'); + } + $this->container['models'] = $models; + + return $this; + } + + /** + * Gets currency + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets region_id + * + * @return int|null + */ + public function getRegionId() + { + return $this->container['region_id']; + } + + /** + * Sets region_id + * + * @param int|null $region_id Идентификатор региона, для которого выводится информация о предложениях модели (доставляемых в этот регион). Информацию о регионе по идентификатору можно получить с помощью запроса [GET regions/{regionId}](../../reference/regions/searchRegionsById.md). + * + * @return self + */ + public function setRegionId($region_id) + { + if (is_null($region_id)) { + throw new \InvalidArgumentException('non-nullable region_id cannot be null'); + } + $this->container['region_id'] = $region_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferCardsContentStatusRequest.php b/erp24/lib/yandex_market_api/Model/GetOfferCardsContentStatusRequest.php new file mode 100644 index 00000000..56092086 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferCardsContentStatusRequest.php @@ -0,0 +1,516 @@ + + */ +class GetOfferCardsContentStatusRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferCardsContentStatusRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]', + 'card_statuses' => '\OpenAPI\Client\Model\OfferCardStatusType[]', + 'category_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null, + 'card_statuses' => null, + 'category_ids' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => true, + 'card_statuses' => true, + 'category_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds', + 'card_statuses' => 'cardStatuses', + 'category_ids' => 'categoryIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds', + 'card_statuses' => 'setCardStatuses', + 'category_ids' => 'setCategoryIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds', + 'card_statuses' => 'getCardStatuses', + 'category_ids' => 'getCategoryIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + $this->setIfExists('card_statuses', $data ?? [], null); + $this->setIfExists('category_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) > 200)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 200."; + } + + if (!is_null($this->container['category_ids']) && (count($this->container['category_ids']) > 200)) { + $invalidProperties[] = "invalid value for 'category_ids', number of items must be less than or equal to 200."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[]|null + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[]|null $offer_ids Идентификаторы товаров, информация о которых нужна.

                  ⚠️ Не используйте это поле одновременно с фильтрами по статусам карточек, категориям, брендам или тегам. Если вы хотите воспользоваться фильтрами, оставьте поле пустым. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($offer_ids) && (count($offer_ids) > 200)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling GetOfferCardsContentStatusRequest., number of items must be less than or equal to 200.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + + /** + * Gets card_statuses + * + * @return \OpenAPI\Client\Model\OfferCardStatusType[]|null + */ + public function getCardStatuses() + { + return $this->container['card_statuses']; + } + + /** + * Sets card_statuses + * + * @param \OpenAPI\Client\Model\OfferCardStatusType[]|null $card_statuses Фильтр по статусам карточек. [Что такое карточка товара](https://yandex.ru/support/marketplace/assortment/content/index.html) + * + * @return self + */ + public function setCardStatuses($card_statuses) + { + if (is_null($card_statuses)) { + array_push($this->openAPINullablesSetToNull, 'card_statuses'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('card_statuses', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + $this->container['card_statuses'] = $card_statuses; + + return $this; + } + + /** + * Gets category_ids + * + * @return int[]|null + */ + public function getCategoryIds() + { + return $this->container['category_ids']; + } + + /** + * Sets category_ids + * + * @param int[]|null $category_ids Фильтр по категориям на Маркете. + * + * @return self + */ + public function setCategoryIds($category_ids) + { + if (is_null($category_ids)) { + array_push($this->openAPINullablesSetToNull, 'category_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('category_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($category_ids) && (count($category_ids) > 200)) { + throw new \InvalidArgumentException('invalid value for $category_ids when calling GetOfferCardsContentStatusRequest., number of items must be less than or equal to 200.'); + } + $this->container['category_ids'] = $category_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferCardsContentStatusResponse.php b/erp24/lib/yandex_market_api/Model/GetOfferCardsContentStatusResponse.php new file mode 100644 index 00000000..d18428b4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferCardsContentStatusResponse.php @@ -0,0 +1,444 @@ + + */ +class GetOfferCardsContentStatusResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferCardsContentStatusResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OfferCardsContentStatusDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OfferCardsContentStatusDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OfferCardsContentStatusDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferDTO.php b/erp24/lib/yandex_market_api/Model/GetOfferDTO.php new file mode 100644 index 00000000..d0d114e9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferDTO.php @@ -0,0 +1,1661 @@ + + */ +class GetOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'name' => 'string', + 'market_category_id' => 'int', + 'category' => 'string', + 'pictures' => 'string[]', + 'videos' => 'string[]', + 'manuals' => '\OpenAPI\Client\Model\OfferManualDTO[]', + 'vendor' => 'string', + 'barcodes' => 'string[]', + 'description' => 'string', + 'manufacturer_countries' => 'string[]', + 'weight_dimensions' => '\OpenAPI\Client\Model\OfferWeightDimensionsDTO', + 'vendor_code' => 'string', + 'tags' => 'string[]', + 'shelf_life' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'life_time' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'guarantee_period' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'customs_commodity_code' => 'string', + 'certificates' => 'string[]', + 'box_count' => 'int', + 'condition' => '\OpenAPI\Client\Model\OfferConditionDTO', + 'type' => '\OpenAPI\Client\Model\OfferType', + 'downloadable' => 'bool', + 'adult' => 'bool', + 'age' => '\OpenAPI\Client\Model\AgeDTO', + 'params' => '\OpenAPI\Client\Model\OfferParamDTO[]', + 'basic_price' => '\OpenAPI\Client\Model\GetPriceWithDiscountDTO', + 'purchase_price' => '\OpenAPI\Client\Model\GetPriceDTO', + 'additional_expenses' => '\OpenAPI\Client\Model\GetPriceDTO', + 'cofinance_price' => '\OpenAPI\Client\Model\GetPriceDTO', + 'card_status' => '\OpenAPI\Client\Model\OfferCardStatusType', + 'campaigns' => '\OpenAPI\Client\Model\OfferCampaignStatusDTO[]', + 'selling_programs' => '\OpenAPI\Client\Model\OfferSellingProgramDTO[]', + 'archived' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'name' => null, + 'market_category_id' => 'int64', + 'category' => null, + 'pictures' => null, + 'videos' => null, + 'manuals' => null, + 'vendor' => null, + 'barcodes' => null, + 'description' => null, + 'manufacturer_countries' => null, + 'weight_dimensions' => null, + 'vendor_code' => null, + 'tags' => null, + 'shelf_life' => null, + 'life_time' => null, + 'guarantee_period' => null, + 'customs_commodity_code' => null, + 'certificates' => null, + 'box_count' => 'int32', + 'condition' => null, + 'type' => null, + 'downloadable' => null, + 'adult' => null, + 'age' => null, + 'params' => null, + 'basic_price' => null, + 'purchase_price' => null, + 'additional_expenses' => null, + 'cofinance_price' => null, + 'card_status' => null, + 'campaigns' => null, + 'selling_programs' => null, + 'archived' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'name' => false, + 'market_category_id' => false, + 'category' => false, + 'pictures' => true, + 'videos' => true, + 'manuals' => true, + 'vendor' => false, + 'barcodes' => true, + 'description' => false, + 'manufacturer_countries' => true, + 'weight_dimensions' => false, + 'vendor_code' => false, + 'tags' => true, + 'shelf_life' => false, + 'life_time' => false, + 'guarantee_period' => false, + 'customs_commodity_code' => false, + 'certificates' => true, + 'box_count' => false, + 'condition' => false, + 'type' => false, + 'downloadable' => false, + 'adult' => false, + 'age' => false, + 'params' => true, + 'basic_price' => false, + 'purchase_price' => false, + 'additional_expenses' => false, + 'cofinance_price' => false, + 'card_status' => false, + 'campaigns' => true, + 'selling_programs' => true, + 'archived' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'name' => 'name', + 'market_category_id' => 'marketCategoryId', + 'category' => 'category', + 'pictures' => 'pictures', + 'videos' => 'videos', + 'manuals' => 'manuals', + 'vendor' => 'vendor', + 'barcodes' => 'barcodes', + 'description' => 'description', + 'manufacturer_countries' => 'manufacturerCountries', + 'weight_dimensions' => 'weightDimensions', + 'vendor_code' => 'vendorCode', + 'tags' => 'tags', + 'shelf_life' => 'shelfLife', + 'life_time' => 'lifeTime', + 'guarantee_period' => 'guaranteePeriod', + 'customs_commodity_code' => 'customsCommodityCode', + 'certificates' => 'certificates', + 'box_count' => 'boxCount', + 'condition' => 'condition', + 'type' => 'type', + 'downloadable' => 'downloadable', + 'adult' => 'adult', + 'age' => 'age', + 'params' => 'params', + 'basic_price' => 'basicPrice', + 'purchase_price' => 'purchasePrice', + 'additional_expenses' => 'additionalExpenses', + 'cofinance_price' => 'cofinancePrice', + 'card_status' => 'cardStatus', + 'campaigns' => 'campaigns', + 'selling_programs' => 'sellingPrograms', + 'archived' => 'archived' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'name' => 'setName', + 'market_category_id' => 'setMarketCategoryId', + 'category' => 'setCategory', + 'pictures' => 'setPictures', + 'videos' => 'setVideos', + 'manuals' => 'setManuals', + 'vendor' => 'setVendor', + 'barcodes' => 'setBarcodes', + 'description' => 'setDescription', + 'manufacturer_countries' => 'setManufacturerCountries', + 'weight_dimensions' => 'setWeightDimensions', + 'vendor_code' => 'setVendorCode', + 'tags' => 'setTags', + 'shelf_life' => 'setShelfLife', + 'life_time' => 'setLifeTime', + 'guarantee_period' => 'setGuaranteePeriod', + 'customs_commodity_code' => 'setCustomsCommodityCode', + 'certificates' => 'setCertificates', + 'box_count' => 'setBoxCount', + 'condition' => 'setCondition', + 'type' => 'setType', + 'downloadable' => 'setDownloadable', + 'adult' => 'setAdult', + 'age' => 'setAge', + 'params' => 'setParams', + 'basic_price' => 'setBasicPrice', + 'purchase_price' => 'setPurchasePrice', + 'additional_expenses' => 'setAdditionalExpenses', + 'cofinance_price' => 'setCofinancePrice', + 'card_status' => 'setCardStatus', + 'campaigns' => 'setCampaigns', + 'selling_programs' => 'setSellingPrograms', + 'archived' => 'setArchived' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'name' => 'getName', + 'market_category_id' => 'getMarketCategoryId', + 'category' => 'getCategory', + 'pictures' => 'getPictures', + 'videos' => 'getVideos', + 'manuals' => 'getManuals', + 'vendor' => 'getVendor', + 'barcodes' => 'getBarcodes', + 'description' => 'getDescription', + 'manufacturer_countries' => 'getManufacturerCountries', + 'weight_dimensions' => 'getWeightDimensions', + 'vendor_code' => 'getVendorCode', + 'tags' => 'getTags', + 'shelf_life' => 'getShelfLife', + 'life_time' => 'getLifeTime', + 'guarantee_period' => 'getGuaranteePeriod', + 'customs_commodity_code' => 'getCustomsCommodityCode', + 'certificates' => 'getCertificates', + 'box_count' => 'getBoxCount', + 'condition' => 'getCondition', + 'type' => 'getType', + 'downloadable' => 'getDownloadable', + 'adult' => 'getAdult', + 'age' => 'getAge', + 'params' => 'getParams', + 'basic_price' => 'getBasicPrice', + 'purchase_price' => 'getPurchasePrice', + 'additional_expenses' => 'getAdditionalExpenses', + 'cofinance_price' => 'getCofinancePrice', + 'card_status' => 'getCardStatus', + 'campaigns' => 'getCampaigns', + 'selling_programs' => 'getSellingPrograms', + 'archived' => 'getArchived' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('market_category_id', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); + $this->setIfExists('pictures', $data ?? [], null); + $this->setIfExists('videos', $data ?? [], null); + $this->setIfExists('manuals', $data ?? [], null); + $this->setIfExists('vendor', $data ?? [], null); + $this->setIfExists('barcodes', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('manufacturer_countries', $data ?? [], null); + $this->setIfExists('weight_dimensions', $data ?? [], null); + $this->setIfExists('vendor_code', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); + $this->setIfExists('shelf_life', $data ?? [], null); + $this->setIfExists('life_time', $data ?? [], null); + $this->setIfExists('guarantee_period', $data ?? [], null); + $this->setIfExists('customs_commodity_code', $data ?? [], null); + $this->setIfExists('certificates', $data ?? [], null); + $this->setIfExists('box_count', $data ?? [], null); + $this->setIfExists('condition', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('downloadable', $data ?? [], null); + $this->setIfExists('adult', $data ?? [], null); + $this->setIfExists('age', $data ?? [], null); + $this->setIfExists('params', $data ?? [], null); + $this->setIfExists('basic_price', $data ?? [], null); + $this->setIfExists('purchase_price', $data ?? [], null); + $this->setIfExists('additional_expenses', $data ?? [], null); + $this->setIfExists('cofinance_price', $data ?? [], null); + $this->setIfExists('card_status', $data ?? [], null); + $this->setIfExists('campaigns', $data ?? [], null); + $this->setIfExists('selling_programs', $data ?? [], null); + $this->setIfExists('archived', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 256)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['videos']) && (count($this->container['videos']) > 6)) { + $invalidProperties[] = "invalid value for 'videos', number of items must be less than or equal to 6."; + } + + if (!is_null($this->container['manuals']) && (count($this->container['manuals']) > 6)) { + $invalidProperties[] = "invalid value for 'manuals', number of items must be less than or equal to 6."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 6000)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 6000."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling GetOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling GetOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling GetOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Составляйте название по схеме: тип + бренд или производитель + модель + особенности, если есть (например, цвет, размер или вес) и количество в упаковке. Не включайте в название условия продажи (например, «скидка», «бесплатная доставка» и т. д.), эмоциональные характеристики («хит», «супер» и т. д.). Не пишите слова большими буквами — кроме устоявшихся названий брендов и моделей. Оптимальная длина — 50–60 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/title.html) + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + if ((mb_strlen($name) > 256)) { + throw new \InvalidArgumentException('invalid length for $name when calling GetOfferDTO., must be smaller than or equal to 256.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets market_category_id + * + * @return int|null + */ + public function getMarketCategoryId() + { + return $this->container['market_category_id']; + } + + /** + * Sets market_category_id + * + * @param int|null $market_category_id Идентификатор категории на Маркете, к которой вы относите свой товар. Если не указать `marketCategoryId`, то маркетная категория будет определена автоматически. При изменении информации о товаре передавайте тот же идентификатор категории. Если вы укажете другой, категория товара не поменяется. Изменить ее можно только в кабинете продавца на Маркете. Список категорий Маркета можно получить с помощью запроса [POST categories/tree](../../reference/categories/getCategoriesTree.md). + * + * @return self + */ + public function setMarketCategoryId($market_category_id) + { + if (is_null($market_category_id)) { + throw new \InvalidArgumentException('non-nullable market_category_id cannot be null'); + } + $this->container['market_category_id'] = $market_category_id; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category Категория товара в вашем магазине. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. Указывайте конкретные категории — например, набор ножей лучше отнести к категории **Столовые приборы**, а не просто **Посуда**. Выбирайте категории, которые описывают товар, а не абстрактный признак — например, **Духи**, а не **Подарки**. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. + * + * @return self + */ + public function setCategory($category) + { + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets pictures + * + * @return string[]|null + */ + public function getPictures() + { + return $this->container['pictures']; + } + + /** + * Sets pictures + * + * @param string[]|null $pictures Ссылки на изображения товара. Изображение по первой ссылке считается основным, остальные дополнительными. **Требования к ссылкам** * Ссылок может быть до 30. * Указывайте ссылку целиком, включая протокол http или https. * Максимальная длина — 512 символов. * Русские буквы в URL можно. * Можно использовать прямые ссылки на изображения и на Яндекс Диск. Ссылки на Яндекс Диске нужно копировать с помощью функции **Поделиться**. Относительные ссылки и ссылки на другие облачные хранилища — не работают. ✅ `https://example-shop.ru/images/sku12345.jpg` ✅ `https://yadi.sk/i/NaBoRsimVOLov` ❌ `/images/sku12345.jpg` ❌ `https://www.dropbox.com/s/818f/tovar.jpg` Ссылки на изображение должны быть постоянными. Нельзя использовать динамические ссылки, меняющиеся от выгрузки к выгрузке. Если нужно заменить изображение, выложите новое изображение по новой ссылке, а ссылку на старое удалите. Если просто заменить изображение по старой ссылке, оно не обновится. [Требования к изображениям](https://yandex.ru/support/marketplace/assortment/fields/images.html) + * + * @return self + */ + public function setPictures($pictures) + { + if (is_null($pictures)) { + array_push($this->openAPINullablesSetToNull, 'pictures'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('pictures', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['pictures'] = $pictures; + + return $this; + } + + /** + * Gets videos + * + * @return string[]|null + */ + public function getVideos() + { + return $this->container['videos']; + } + + /** + * Sets videos + * + * @param string[]|null $videos Ссылка (URL) на видео товара. Максимальное количество ссылок — 6. **Требования к ссылке** * Указывайте ссылку целиком, включая протокол http или https. * Максимальная длина — 512 символов. * Русские буквы в URL можно. * Можно использовать прямые ссылки на видео и на Яндекс Диск. Ссылки на Яндекс Диске нужно копировать с помощью функции **Поделиться**. Относительные ссылки и ссылки на другие облачные хранилища — не работают. ✅ `https://example-shop.ru/video/sku12345.avi` ✅ `https://yadi.sk/i/NaBoRsimVOLov` ❌ `/video/sku12345.avi` ❌ `https://www.dropbox.com/s/818f/super-tovar.avi` Ссылки на видео должны быть постоянными. Нельзя использовать динамические ссылки, меняющиеся от выгрузки к выгрузке. Если нужно заменить видео, выложите новое видео по новой ссылке, а ссылку на старое удалите. Если просто заменить видео по старой ссылке, оно не обновится. [Требования к видео](https://yandex.ru/support/marketplace/assortment/fields/video.html) + * + * @return self + */ + public function setVideos($videos) + { + if (is_null($videos)) { + array_push($this->openAPINullablesSetToNull, 'videos'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('videos', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($videos) && (count($videos) > 6)) { + throw new \InvalidArgumentException('invalid value for $videos when calling GetOfferDTO., number of items must be less than or equal to 6.'); + } + $this->container['videos'] = $videos; + + return $this; + } + + /** + * Gets manuals + * + * @return \OpenAPI\Client\Model\OfferManualDTO[]|null + */ + public function getManuals() + { + return $this->container['manuals']; + } + + /** + * Sets manuals + * + * @param \OpenAPI\Client\Model\OfferManualDTO[]|null $manuals Список инструкций по использованию товара. Максимальное количество инструкций — 6. Если вы передадите пустое поле `manuals`, загруженные ранее инструкции удалятся. + * + * @return self + */ + public function setManuals($manuals) + { + if (is_null($manuals)) { + array_push($this->openAPINullablesSetToNull, 'manuals'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manuals', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($manuals) && (count($manuals) > 6)) { + throw new \InvalidArgumentException('invalid value for $manuals when calling GetOfferDTO., number of items must be less than or equal to 6.'); + } + $this->container['manuals'] = $manuals; + + return $this; + } + + /** + * Gets vendor + * + * @return string|null + */ + public function getVendor() + { + return $this->container['vendor']; + } + + /** + * Sets vendor + * + * @param string|null $vendor Название бренда или производителя. Должно быть записано так, как его пишет сам бренд. + * + * @return self + */ + public function setVendor($vendor) + { + if (is_null($vendor)) { + throw new \InvalidArgumentException('non-nullable vendor cannot be null'); + } + $this->container['vendor'] = $vendor; + + return $this; + } + + /** + * Gets barcodes + * + * @return string[]|null + */ + public function getBarcodes() + { + return $this->container['barcodes']; + } + + /** + * Sets barcodes + * + * @param string[]|null $barcodes Указывайте в виде последовательности цифр. Подойдут коды EAN-13, EAN-8, UPC-A, UPC-E или Code 128. Для книг указывайте ISBN. Для товаров [определенных категорий и торговых марок](https://yastatic.net/s3/doc-binary/src/support/market/ru/yandex-market-list-for-gtin.xlsx) штрихкод должен быть действительным кодом GTIN. Обратите внимание: внутренние штрихкоды, начинающиеся на 2 или 02, и коды формата Code 128 не являются GTIN. [Что такое GTIN](*gtin) + * + * @return self + */ + public function setBarcodes($barcodes) + { + if (is_null($barcodes)) { + array_push($this->openAPINullablesSetToNull, 'barcodes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('barcodes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['barcodes'] = $barcodes; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Подробное описание товара: например, его преимущества и особенности. Не давайте в описании инструкций по установке и сборке. Не используйте слова «скидка», «распродажа», «дешевый», «подарок» (кроме подарочных категорий), «бесплатно», «акция», «специальная цена», «новинка», «new», «аналог», «заказ», «хит». Не указывайте никакой контактной информации и не давайте ссылок. Можно использовать теги: * \\, \\

                  , \\

                  и так далее — для заголовков; * \\
                  и \\

                  — для переноса строки; * \\

                    — для нумерованного списка; * \\
                      — для маркированного списка; * \\
                    • — для создания элементов списка (должен находиться внутри \\
                        или \\
                          ); * \\
                          — поддерживается, но не влияет на отображение текста. Оптимальная длина — 400–600 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/description.html) + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + if ((mb_strlen($description) > 6000)) { + throw new \InvalidArgumentException('invalid length for $description when calling GetOfferDTO., must be smaller than or equal to 6000.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets manufacturer_countries + * + * @return string[]|null + */ + public function getManufacturerCountries() + { + return $this->container['manufacturer_countries']; + } + + /** + * Sets manufacturer_countries + * + * @param string[]|null $manufacturer_countries Страна, где был произведен товар. Записывайте названия стран так, как они записаны в [списке](https://yastatic.net/s3/doc-binary/src/support/market/ru/countries.xlsx). + * + * @return self + */ + public function setManufacturerCountries($manufacturer_countries) + { + if (is_null($manufacturer_countries)) { + array_push($this->openAPINullablesSetToNull, 'manufacturer_countries'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manufacturer_countries', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['manufacturer_countries'] = $manufacturer_countries; + + return $this; + } + + /** + * Gets weight_dimensions + * + * @return \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null + */ + public function getWeightDimensions() + { + return $this->container['weight_dimensions']; + } + + /** + * Sets weight_dimensions + * + * @param \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null $weight_dimensions weight_dimensions + * + * @return self + */ + public function setWeightDimensions($weight_dimensions) + { + if (is_null($weight_dimensions)) { + throw new \InvalidArgumentException('non-nullable weight_dimensions cannot be null'); + } + $this->container['weight_dimensions'] = $weight_dimensions; + + return $this; + } + + /** + * Gets vendor_code + * + * @return string|null + */ + public function getVendorCode() + { + return $this->container['vendor_code']; + } + + /** + * Sets vendor_code + * + * @param string|null $vendor_code Артикул товара от производителя. + * + * @return self + */ + public function setVendorCode($vendor_code) + { + if (is_null($vendor_code)) { + throw new \InvalidArgumentException('non-nullable vendor_code cannot be null'); + } + $this->container['vendor_code'] = $vendor_code; + + return $this; + } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Метки товара, используемые магазином. Покупателям теги не видны. По тегам можно группировать и фильтровать разные товары в каталоге — например, товары одной серии, коллекции или линейки. Максимальная длина тега 20 символов. У одного товара может быть максимум 10 тегов. Всего можно создать не больше 50 разных тегов. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + array_push($this->openAPINullablesSetToNull, 'tags'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tags', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tags'] = $tags; + + return $this; + } + + /** + * Gets shelf_life + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getShelfLife() + { + return $this->container['shelf_life']; + } + + /** + * Sets shelf_life + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $shelf_life shelf_life + * + * @return self + */ + public function setShelfLife($shelf_life) + { + if (is_null($shelf_life)) { + throw new \InvalidArgumentException('non-nullable shelf_life cannot be null'); + } + $this->container['shelf_life'] = $shelf_life; + + return $this; + } + + /** + * Gets life_time + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getLifeTime() + { + return $this->container['life_time']; + } + + /** + * Sets life_time + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $life_time life_time + * + * @return self + */ + public function setLifeTime($life_time) + { + if (is_null($life_time)) { + throw new \InvalidArgumentException('non-nullable life_time cannot be null'); + } + $this->container['life_time'] = $life_time; + + return $this; + } + + /** + * Gets guarantee_period + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getGuaranteePeriod() + { + return $this->container['guarantee_period']; + } + + /** + * Sets guarantee_period + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $guarantee_period guarantee_period + * + * @return self + */ + public function setGuaranteePeriod($guarantee_period) + { + if (is_null($guarantee_period)) { + throw new \InvalidArgumentException('non-nullable guarantee_period cannot be null'); + } + $this->container['guarantee_period'] = $guarantee_period; + + return $this; + } + + /** + * Gets customs_commodity_code + * + * @return string|null + */ + public function getCustomsCommodityCode() + { + return $this->container['customs_commodity_code']; + } + + /** + * Sets customs_commodity_code + * + * @param string|null $customs_commodity_code Код товара в единой Товарной номенклатуре внешнеэкономической деятельности (ТН ВЭД) — 10 или 14 цифр без пробелов. Обязательно укажите, если он есть. + * + * @return self + */ + public function setCustomsCommodityCode($customs_commodity_code) + { + if (is_null($customs_commodity_code)) { + throw new \InvalidArgumentException('non-nullable customs_commodity_code cannot be null'); + } + $this->container['customs_commodity_code'] = $customs_commodity_code; + + return $this; + } + + /** + * Gets certificates + * + * @return string[]|null + */ + public function getCertificates() + { + return $this->container['certificates']; + } + + /** + * Sets certificates + * + * @param string[]|null $certificates Номера документов на товар: сертификата, декларации соответствия и т. п. Передавать можно только номера документов, сканы которого загружены в кабинете продавца по [инструкции](https://yandex.ru/support/marketplace/assortment/restrictions/certificates.html). + * + * @return self + */ + public function setCertificates($certificates) + { + if (is_null($certificates)) { + array_push($this->openAPINullablesSetToNull, 'certificates'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('certificates', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['certificates'] = $certificates; + + return $this; + } + + /** + * Gets box_count + * + * @return int|null + */ + public function getBoxCount() + { + return $this->container['box_count']; + } + + /** + * Sets box_count + * + * @param int|null $box_count Количество грузовых мест. Параметр используется, если товар представляет собой несколько коробок, упаковок и так далее. Например, кондиционер занимает два места — внешний и внутренний блоки в двух коробках. Для товаров, занимающих одно место, не передавайте этот параметр. + * + * @return self + */ + public function setBoxCount($box_count) + { + if (is_null($box_count)) { + throw new \InvalidArgumentException('non-nullable box_count cannot be null'); + } + $this->container['box_count'] = $box_count; + + return $this; + } + + /** + * Gets condition + * + * @return \OpenAPI\Client\Model\OfferConditionDTO|null + */ + public function getCondition() + { + return $this->container['condition']; + } + + /** + * Sets condition + * + * @param \OpenAPI\Client\Model\OfferConditionDTO|null $condition condition + * + * @return self + */ + public function setCondition($condition) + { + if (is_null($condition)) { + throw new \InvalidArgumentException('non-nullable condition cannot be null'); + } + $this->container['condition'] = $condition; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OfferType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OfferType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets downloadable + * + * @return bool|null + */ + public function getDownloadable() + { + return $this->container['downloadable']; + } + + /** + * Sets downloadable + * + * @param bool|null $downloadable Признак цифрового товара. Укажите `true`, если товар доставляется по электронной почте. [Как работать с цифровыми товарами](../../step-by-step/digital.md) + * + * @return self + */ + public function setDownloadable($downloadable) + { + if (is_null($downloadable)) { + throw new \InvalidArgumentException('non-nullable downloadable cannot be null'); + } + $this->container['downloadable'] = $downloadable; + + return $this; + } + + /** + * Gets adult + * + * @return bool|null + */ + public function getAdult() + { + return $this->container['adult']; + } + + /** + * Sets adult + * + * @param bool|null $adult Параметр включает для товара пометку 18+. Устанавливайте ее только для товаров, которые относятся к удовлетворению сексуальных потребностей. + * + * @return self + */ + public function setAdult($adult) + { + if (is_null($adult)) { + throw new \InvalidArgumentException('non-nullable adult cannot be null'); + } + $this->container['adult'] = $adult; + + return $this; + } + + /** + * Gets age + * + * @return \OpenAPI\Client\Model\AgeDTO|null + */ + public function getAge() + { + return $this->container['age']; + } + + /** + * Sets age + * + * @param \OpenAPI\Client\Model\AgeDTO|null $age age + * + * @return self + */ + public function setAge($age) + { + if (is_null($age)) { + throw new \InvalidArgumentException('non-nullable age cannot be null'); + } + $this->container['age'] = $age; + + return $this; + } + + /** + * Gets params + * + * @return \OpenAPI\Client\Model\OfferParamDTO[]|null + * @deprecated + */ + public function getParams() + { + return $this->container['params']; + } + + /** + * Sets params + * + * @param \OpenAPI\Client\Model\OfferParamDTO[]|null $params {% note warning \"\" %} Этот параметр устарел. При передаче характеристик используйте `parameterValues`. {% endnote %} Характеристики, которые есть только у товаров конкретной категории — например, диаметр колес велосипеда или материал подошвы обуви. + * + * @return self + * @deprecated + */ + public function setParams($params) + { + if (is_null($params)) { + array_push($this->openAPINullablesSetToNull, 'params'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('params', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['params'] = $params; + + return $this; + } + + /** + * Gets basic_price + * + * @return \OpenAPI\Client\Model\GetPriceWithDiscountDTO|null + */ + public function getBasicPrice() + { + return $this->container['basic_price']; + } + + /** + * Sets basic_price + * + * @param \OpenAPI\Client\Model\GetPriceWithDiscountDTO|null $basic_price basic_price + * + * @return self + */ + public function setBasicPrice($basic_price) + { + if (is_null($basic_price)) { + throw new \InvalidArgumentException('non-nullable basic_price cannot be null'); + } + $this->container['basic_price'] = $basic_price; + + return $this; + } + + /** + * Gets purchase_price + * + * @return \OpenAPI\Client\Model\GetPriceDTO|null + */ + public function getPurchasePrice() + { + return $this->container['purchase_price']; + } + + /** + * Sets purchase_price + * + * @param \OpenAPI\Client\Model\GetPriceDTO|null $purchase_price purchase_price + * + * @return self + */ + public function setPurchasePrice($purchase_price) + { + if (is_null($purchase_price)) { + throw new \InvalidArgumentException('non-nullable purchase_price cannot be null'); + } + $this->container['purchase_price'] = $purchase_price; + + return $this; + } + + /** + * Gets additional_expenses + * + * @return \OpenAPI\Client\Model\GetPriceDTO|null + */ + public function getAdditionalExpenses() + { + return $this->container['additional_expenses']; + } + + /** + * Sets additional_expenses + * + * @param \OpenAPI\Client\Model\GetPriceDTO|null $additional_expenses additional_expenses + * + * @return self + */ + public function setAdditionalExpenses($additional_expenses) + { + if (is_null($additional_expenses)) { + throw new \InvalidArgumentException('non-nullable additional_expenses cannot be null'); + } + $this->container['additional_expenses'] = $additional_expenses; + + return $this; + } + + /** + * Gets cofinance_price + * + * @return \OpenAPI\Client\Model\GetPriceDTO|null + */ + public function getCofinancePrice() + { + return $this->container['cofinance_price']; + } + + /** + * Sets cofinance_price + * + * @param \OpenAPI\Client\Model\GetPriceDTO|null $cofinance_price cofinance_price + * + * @return self + */ + public function setCofinancePrice($cofinance_price) + { + if (is_null($cofinance_price)) { + throw new \InvalidArgumentException('non-nullable cofinance_price cannot be null'); + } + $this->container['cofinance_price'] = $cofinance_price; + + return $this; + } + + /** + * Gets card_status + * + * @return \OpenAPI\Client\Model\OfferCardStatusType|null + */ + public function getCardStatus() + { + return $this->container['card_status']; + } + + /** + * Sets card_status + * + * @param \OpenAPI\Client\Model\OfferCardStatusType|null $card_status card_status + * + * @return self + */ + public function setCardStatus($card_status) + { + if (is_null($card_status)) { + throw new \InvalidArgumentException('non-nullable card_status cannot be null'); + } + $this->container['card_status'] = $card_status; + + return $this; + } + + /** + * Gets campaigns + * + * @return \OpenAPI\Client\Model\OfferCampaignStatusDTO[]|null + */ + public function getCampaigns() + { + return $this->container['campaigns']; + } + + /** + * Sets campaigns + * + * @param \OpenAPI\Client\Model\OfferCampaignStatusDTO[]|null $campaigns Список магазинов, в которых размещен товар. + * + * @return self + */ + public function setCampaigns($campaigns) + { + if (is_null($campaigns)) { + array_push($this->openAPINullablesSetToNull, 'campaigns'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('campaigns', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['campaigns'] = $campaigns; + + return $this; + } + + /** + * Gets selling_programs + * + * @return \OpenAPI\Client\Model\OfferSellingProgramDTO[]|null + */ + public function getSellingPrograms() + { + return $this->container['selling_programs']; + } + + /** + * Sets selling_programs + * + * @param \OpenAPI\Client\Model\OfferSellingProgramDTO[]|null $selling_programs Информация о том, какие для товара доступны модели размещения. + * + * @return self + */ + public function setSellingPrograms($selling_programs) + { + if (is_null($selling_programs)) { + array_push($this->openAPINullablesSetToNull, 'selling_programs'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('selling_programs', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['selling_programs'] = $selling_programs; + + return $this; + } + + /** + * Gets archived + * + * @return bool|null + */ + public function getArchived() + { + return $this->container['archived']; + } + + /** + * Sets archived + * + * @param bool|null $archived Товар помещен в архив. + * + * @return self + */ + public function setArchived($archived) + { + if (is_null($archived)) { + throw new \InvalidArgumentException('non-nullable archived cannot be null'); + } + $this->container['archived'] = $archived; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferMappingDTO.php b/erp24/lib/yandex_market_api/Model/GetOfferMappingDTO.php new file mode 100644 index 00000000..e878cfd4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferMappingDTO.php @@ -0,0 +1,444 @@ + + */ +class GetOfferMappingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferMappingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer' => '\OpenAPI\Client\Model\GetOfferDTO', + 'mapping' => '\OpenAPI\Client\Model\GetMappingDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer' => null, + 'mapping' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer' => false, + 'mapping' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer' => 'offer', + 'mapping' => 'mapping' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer' => 'setOffer', + 'mapping' => 'setMapping' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer' => 'getOffer', + 'mapping' => 'getMapping' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer', $data ?? [], null); + $this->setIfExists('mapping', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer + * + * @return \OpenAPI\Client\Model\GetOfferDTO|null + */ + public function getOffer() + { + return $this->container['offer']; + } + + /** + * Sets offer + * + * @param \OpenAPI\Client\Model\GetOfferDTO|null $offer offer + * + * @return self + */ + public function setOffer($offer) + { + if (is_null($offer)) { + throw new \InvalidArgumentException('non-nullable offer cannot be null'); + } + $this->container['offer'] = $offer; + + return $this; + } + + /** + * Gets mapping + * + * @return \OpenAPI\Client\Model\GetMappingDTO|null + */ + public function getMapping() + { + return $this->container['mapping']; + } + + /** + * Sets mapping + * + * @param \OpenAPI\Client\Model\GetMappingDTO|null $mapping mapping + * + * @return self + */ + public function setMapping($mapping) + { + if (is_null($mapping)) { + throw new \InvalidArgumentException('non-nullable mapping cannot be null'); + } + $this->container['mapping'] = $mapping; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferMappingEntriesResponse.php b/erp24/lib/yandex_market_api/Model/GetOfferMappingEntriesResponse.php new file mode 100644 index 00000000..191d59cb --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferMappingEntriesResponse.php @@ -0,0 +1,444 @@ + + */ +class GetOfferMappingEntriesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferMappingEntriesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OfferMappingEntriesDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OfferMappingEntriesDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OfferMappingEntriesDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferMappingsRequest.php b/erp24/lib/yandex_market_api/Model/GetOfferMappingsRequest.php new file mode 100644 index 00000000..c9b391de --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferMappingsRequest.php @@ -0,0 +1,665 @@ + + */ +class GetOfferMappingsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferMappingsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]', + 'card_statuses' => '\OpenAPI\Client\Model\OfferCardStatusType[]', + 'category_ids' => 'int[]', + 'vendor_names' => 'string[]', + 'tags' => 'string[]', + 'archived' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null, + 'card_statuses' => null, + 'category_ids' => null, + 'vendor_names' => null, + 'tags' => null, + 'archived' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => true, + 'card_statuses' => true, + 'category_ids' => true, + 'vendor_names' => true, + 'tags' => true, + 'archived' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds', + 'card_statuses' => 'cardStatuses', + 'category_ids' => 'categoryIds', + 'vendor_names' => 'vendorNames', + 'tags' => 'tags', + 'archived' => 'archived' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds', + 'card_statuses' => 'setCardStatuses', + 'category_ids' => 'setCategoryIds', + 'vendor_names' => 'setVendorNames', + 'tags' => 'setTags', + 'archived' => 'setArchived' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds', + 'card_statuses' => 'getCardStatuses', + 'category_ids' => 'getCategoryIds', + 'vendor_names' => 'getVendorNames', + 'tags' => 'getTags', + 'archived' => 'getArchived' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + $this->setIfExists('card_statuses', $data ?? [], null); + $this->setIfExists('category_ids', $data ?? [], null); + $this->setIfExists('vendor_names', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); + $this->setIfExists('archived', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) > 200)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 200."; + } + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['card_statuses']) && (count($this->container['card_statuses']) < 1)) { + $invalidProperties[] = "invalid value for 'card_statuses', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['category_ids']) && (count($this->container['category_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'category_ids', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['vendor_names']) && (count($this->container['vendor_names']) < 1)) { + $invalidProperties[] = "invalid value for 'vendor_names', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['tags']) && (count($this->container['tags']) < 1)) { + $invalidProperties[] = "invalid value for 'tags', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[]|null + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[]|null $offer_ids Идентификаторы товаров, информация о которых нужна. {% note warning \"Такой список возвращается только целиком\" %} Если вы запрашиваете информацию по конкретным SKU, не заполняйте: * `page_token`; * `limit`; * `cardStatuses`; * `categoryIds`; * `vendorNames`; * `tags`; * `archived`. {% endnote %}   + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($offer_ids) && (count($offer_ids) > 200)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling GetOfferMappingsRequest., number of items must be less than or equal to 200.'); + } + if (!is_null($offer_ids) && (count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling GetOfferMappingsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + + /** + * Gets card_statuses + * + * @return \OpenAPI\Client\Model\OfferCardStatusType[]|null + */ + public function getCardStatuses() + { + return $this->container['card_statuses']; + } + + /** + * Sets card_statuses + * + * @param \OpenAPI\Client\Model\OfferCardStatusType[]|null $card_statuses Фильтр по статусам карточек. [Что такое карточка товара](https://yandex.ru/support/marketplace/assortment/content/index.html) + * + * @return self + */ + public function setCardStatuses($card_statuses) + { + if (is_null($card_statuses)) { + array_push($this->openAPINullablesSetToNull, 'card_statuses'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('card_statuses', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($card_statuses) && (count($card_statuses) < 1)) { + throw new \InvalidArgumentException('invalid length for $card_statuses when calling GetOfferMappingsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['card_statuses'] = $card_statuses; + + return $this; + } + + /** + * Gets category_ids + * + * @return int[]|null + */ + public function getCategoryIds() + { + return $this->container['category_ids']; + } + + /** + * Sets category_ids + * + * @param int[]|null $category_ids Фильтр по категориям на Маркете. + * + * @return self + */ + public function setCategoryIds($category_ids) + { + if (is_null($category_ids)) { + array_push($this->openAPINullablesSetToNull, 'category_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('category_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($category_ids) && (count($category_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $category_ids when calling GetOfferMappingsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['category_ids'] = $category_ids; + + return $this; + } + + /** + * Gets vendor_names + * + * @return string[]|null + */ + public function getVendorNames() + { + return $this->container['vendor_names']; + } + + /** + * Sets vendor_names + * + * @param string[]|null $vendor_names Фильтр по брендам. + * + * @return self + */ + public function setVendorNames($vendor_names) + { + if (is_null($vendor_names)) { + array_push($this->openAPINullablesSetToNull, 'vendor_names'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('vendor_names', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($vendor_names) && (count($vendor_names) < 1)) { + throw new \InvalidArgumentException('invalid length for $vendor_names when calling GetOfferMappingsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['vendor_names'] = $vendor_names; + + return $this; + } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Фильтр по тегам. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + array_push($this->openAPINullablesSetToNull, 'tags'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tags', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($tags) && (count($tags) < 1)) { + throw new \InvalidArgumentException('invalid length for $tags when calling GetOfferMappingsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['tags'] = $tags; + + return $this; + } + + /** + * Gets archived + * + * @return bool|null + */ + public function getArchived() + { + return $this->container['archived']; + } + + /** + * Sets archived + * + * @param bool|null $archived Фильтр по нахождению в архиве. Передайте `true`, чтобы получить товары, находящиеся в архиве. Если фильтр не заполнен или передано `false`, в ответе возвращаются товары, не находящиеся в архиве. + * + * @return self + */ + public function setArchived($archived) + { + if (is_null($archived)) { + throw new \InvalidArgumentException('non-nullable archived cannot be null'); + } + $this->container['archived'] = $archived; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferMappingsResponse.php b/erp24/lib/yandex_market_api/Model/GetOfferMappingsResponse.php new file mode 100644 index 00000000..2b75ab72 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferMappingsResponse.php @@ -0,0 +1,443 @@ + + */ +class GetOfferMappingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferMappingsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetOfferMappingsResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetOfferMappingsResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetOfferMappingsResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferMappingsResultDTO.php b/erp24/lib/yandex_market_api/Model/GetOfferMappingsResultDTO.php new file mode 100644 index 00000000..764927b1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferMappingsResultDTO.php @@ -0,0 +1,447 @@ + + */ +class GetOfferMappingsResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferMappingsResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'offer_mappings' => '\OpenAPI\Client\Model\GetOfferMappingDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'offer_mappings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'offer_mappings' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'offer_mappings' => 'offerMappings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'offer_mappings' => 'setOfferMappings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'offer_mappings' => 'getOfferMappings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('offer_mappings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_mappings'] === null) { + $invalidProperties[] = "'offer_mappings' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets offer_mappings + * + * @return \OpenAPI\Client\Model\GetOfferMappingDTO[] + */ + public function getOfferMappings() + { + return $this->container['offer_mappings']; + } + + /** + * Sets offer_mappings + * + * @param \OpenAPI\Client\Model\GetOfferMappingDTO[] $offer_mappings Информация о товарах. + * + * @return self + */ + public function setOfferMappings($offer_mappings) + { + if (is_null($offer_mappings)) { + throw new \InvalidArgumentException('non-nullable offer_mappings cannot be null'); + } + $this->container['offer_mappings'] = $offer_mappings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferRecommendationsRequest.php b/erp24/lib/yandex_market_api/Model/GetOfferRecommendationsRequest.php new file mode 100644 index 00000000..ed3fedd4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferRecommendationsRequest.php @@ -0,0 +1,518 @@ + + */ +class GetOfferRecommendationsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferRecommendationsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]', + 'cofinance_price_filter' => '\OpenAPI\Client\Model\FieldStateType', + 'recommended_cofinance_price_filter' => '\OpenAPI\Client\Model\FieldStateType', + 'competitiveness_filter' => '\OpenAPI\Client\Model\PriceCompetitivenessType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null, + 'cofinance_price_filter' => null, + 'recommended_cofinance_price_filter' => null, + 'competitiveness_filter' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => true, + 'cofinance_price_filter' => false, + 'recommended_cofinance_price_filter' => false, + 'competitiveness_filter' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds', + 'cofinance_price_filter' => 'cofinancePriceFilter', + 'recommended_cofinance_price_filter' => 'recommendedCofinancePriceFilter', + 'competitiveness_filter' => 'competitivenessFilter' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds', + 'cofinance_price_filter' => 'setCofinancePriceFilter', + 'recommended_cofinance_price_filter' => 'setRecommendedCofinancePriceFilter', + 'competitiveness_filter' => 'setCompetitivenessFilter' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds', + 'cofinance_price_filter' => 'getCofinancePriceFilter', + 'recommended_cofinance_price_filter' => 'getRecommendedCofinancePriceFilter', + 'competitiveness_filter' => 'getCompetitivenessFilter' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + $this->setIfExists('cofinance_price_filter', $data ?? [], null); + $this->setIfExists('recommended_cofinance_price_filter', $data ?? [], null); + $this->setIfExists('competitiveness_filter', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[]|null + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[]|null $offer_ids Идентификаторы товаров, информация о которых нужна. ⚠️ Не используйте это поле одновременно с остальными фильтрами. Если вы хотите воспользоваться фильтрами, оставьте поле пустым. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + + /** + * Gets cofinance_price_filter + * + * @return \OpenAPI\Client\Model\FieldStateType|null + */ + public function getCofinancePriceFilter() + { + return $this->container['cofinance_price_filter']; + } + + /** + * Sets cofinance_price_filter + * + * @param \OpenAPI\Client\Model\FieldStateType|null $cofinance_price_filter cofinance_price_filter + * + * @return self + */ + public function setCofinancePriceFilter($cofinance_price_filter) + { + if (is_null($cofinance_price_filter)) { + throw new \InvalidArgumentException('non-nullable cofinance_price_filter cannot be null'); + } + $this->container['cofinance_price_filter'] = $cofinance_price_filter; + + return $this; + } + + /** + * Gets recommended_cofinance_price_filter + * + * @return \OpenAPI\Client\Model\FieldStateType|null + */ + public function getRecommendedCofinancePriceFilter() + { + return $this->container['recommended_cofinance_price_filter']; + } + + /** + * Sets recommended_cofinance_price_filter + * + * @param \OpenAPI\Client\Model\FieldStateType|null $recommended_cofinance_price_filter recommended_cofinance_price_filter + * + * @return self + */ + public function setRecommendedCofinancePriceFilter($recommended_cofinance_price_filter) + { + if (is_null($recommended_cofinance_price_filter)) { + throw new \InvalidArgumentException('non-nullable recommended_cofinance_price_filter cannot be null'); + } + $this->container['recommended_cofinance_price_filter'] = $recommended_cofinance_price_filter; + + return $this; + } + + /** + * Gets competitiveness_filter + * + * @return \OpenAPI\Client\Model\PriceCompetitivenessType|null + */ + public function getCompetitivenessFilter() + { + return $this->container['competitiveness_filter']; + } + + /** + * Sets competitiveness_filter + * + * @param \OpenAPI\Client\Model\PriceCompetitivenessType|null $competitiveness_filter competitiveness_filter + * + * @return self + */ + public function setCompetitivenessFilter($competitiveness_filter) + { + if (is_null($competitiveness_filter)) { + throw new \InvalidArgumentException('non-nullable competitiveness_filter cannot be null'); + } + $this->container['competitiveness_filter'] = $competitiveness_filter; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOfferRecommendationsResponse.php b/erp24/lib/yandex_market_api/Model/GetOfferRecommendationsResponse.php new file mode 100644 index 00000000..70e1a598 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOfferRecommendationsResponse.php @@ -0,0 +1,443 @@ + + */ +class GetOfferRecommendationsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOfferRecommendationsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OfferRecommendationsResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OfferRecommendationsResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OfferRecommendationsResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOffersResponse.php b/erp24/lib/yandex_market_api/Model/GetOffersResponse.php new file mode 100644 index 00000000..e3191221 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOffersResponse.php @@ -0,0 +1,447 @@ + + */ +class GetOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\OfferDTO[]', + 'pager' => '\OpenAPI\Client\Model\FlippingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null, + 'pager' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false, + 'pager' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers', + 'pager' => 'pager' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers', + 'pager' => 'setPager' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers', + 'pager' => 'getPager' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + $this->setIfExists('pager', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\OfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\OfferDTO[] $offers Список предложений магазина. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + + /** + * Gets pager + * + * @return \OpenAPI\Client\Model\FlippingPagerDTO|null + */ + public function getPager() + { + return $this->container['pager']; + } + + /** + * Sets pager + * + * @param \OpenAPI\Client\Model\FlippingPagerDTO|null $pager pager + * + * @return self + */ + public function setPager($pager) + { + if (is_null($pager)) { + throw new \InvalidArgumentException('non-nullable pager cannot be null'); + } + $this->container['pager'] = $pager; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOrderBuyerInfoResponse.php b/erp24/lib/yandex_market_api/Model/GetOrderBuyerInfoResponse.php new file mode 100644 index 00000000..839efc88 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOrderBuyerInfoResponse.php @@ -0,0 +1,443 @@ + + */ +class GetOrderBuyerInfoResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOrderBuyerInfoResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OrderBuyerInfoDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OrderBuyerInfoDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OrderBuyerInfoDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOrderLabelsDataResponse.php b/erp24/lib/yandex_market_api/Model/GetOrderLabelsDataResponse.php new file mode 100644 index 00000000..20275c6d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOrderLabelsDataResponse.php @@ -0,0 +1,444 @@ + + */ +class GetOrderLabelsDataResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOrderLabelsDataResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OrderLabelDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OrderLabelDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OrderLabelDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOrderResponse.php b/erp24/lib/yandex_market_api/Model/GetOrderResponse.php new file mode 100644 index 00000000..0d6891b5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOrderResponse.php @@ -0,0 +1,409 @@ + + */ +class GetOrderResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOrderResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order' => '\OpenAPI\Client\Model\OrderDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order' => 'order' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order' => 'setOrder' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order' => 'getOrder' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order + * + * @return \OpenAPI\Client\Model\OrderDTO|null + */ + public function getOrder() + { + return $this->container['order']; + } + + /** + * Sets order + * + * @param \OpenAPI\Client\Model\OrderDTO|null $order order + * + * @return self + */ + public function setOrder($order) + { + if (is_null($order)) { + throw new \InvalidArgumentException('non-nullable order cannot be null'); + } + $this->container['order'] = $order; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOrdersResponse.php b/erp24/lib/yandex_market_api/Model/GetOrdersResponse.php new file mode 100644 index 00000000..5d6f4394 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOrdersResponse.php @@ -0,0 +1,489 @@ + + */ +class GetOrdersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOrdersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'pager' => '\OpenAPI\Client\Model\FlippingPagerDTO', + 'orders' => '\OpenAPI\Client\Model\OrderDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'pager' => null, + 'orders' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'pager' => false, + 'orders' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'pager' => 'pager', + 'orders' => 'orders', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'pager' => 'setPager', + 'orders' => 'setOrders', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'pager' => 'getPager', + 'orders' => 'getOrders', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('pager', $data ?? [], null); + $this->setIfExists('orders', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['orders'] === null) { + $invalidProperties[] = "'orders' can't be null"; + } + if ((count($this->container['orders']) > 50)) { + $invalidProperties[] = "invalid value for 'orders', number of items must be less than or equal to 50."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets pager + * + * @return \OpenAPI\Client\Model\FlippingPagerDTO|null + */ + public function getPager() + { + return $this->container['pager']; + } + + /** + * Sets pager + * + * @param \OpenAPI\Client\Model\FlippingPagerDTO|null $pager pager + * + * @return self + */ + public function setPager($pager) + { + if (is_null($pager)) { + throw new \InvalidArgumentException('non-nullable pager cannot be null'); + } + $this->container['pager'] = $pager; + + return $this; + } + + /** + * Gets orders + * + * @return \OpenAPI\Client\Model\OrderDTO[] + */ + public function getOrders() + { + return $this->container['orders']; + } + + /** + * Sets orders + * + * @param \OpenAPI\Client\Model\OrderDTO[] $orders Модель заказа. + * + * @return self + */ + public function setOrders($orders) + { + if (is_null($orders)) { + throw new \InvalidArgumentException('non-nullable orders cannot be null'); + } + + if ((count($orders) > 50)) { + throw new \InvalidArgumentException('invalid value for $orders when calling GetOrdersResponse., number of items must be less than or equal to 50.'); + } + $this->container['orders'] = $orders; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOrdersStatsRequest.php b/erp24/lib/yandex_market_api/Model/GetOrdersStatsRequest.php new file mode 100644 index 00000000..deefc75c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOrdersStatsRequest.php @@ -0,0 +1,628 @@ + + */ +class GetOrdersStatsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOrdersStatsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'update_from' => '\DateTime', + 'update_to' => '\DateTime', + 'orders' => 'int[]', + 'statuses' => '\OpenAPI\Client\Model\OrderStatsStatusType[]', + 'has_cis' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'date_from' => 'date', + 'date_to' => 'date', + 'update_from' => 'date', + 'update_to' => 'date', + 'orders' => 'int64', + 'statuses' => null, + 'has_cis' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'date_from' => false, + 'date_to' => false, + 'update_from' => false, + 'update_to' => false, + 'orders' => true, + 'statuses' => true, + 'has_cis' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'update_from' => 'updateFrom', + 'update_to' => 'updateTo', + 'orders' => 'orders', + 'statuses' => 'statuses', + 'has_cis' => 'hasCis' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'update_from' => 'setUpdateFrom', + 'update_to' => 'setUpdateTo', + 'orders' => 'setOrders', + 'statuses' => 'setStatuses', + 'has_cis' => 'setHasCis' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'update_from' => 'getUpdateFrom', + 'update_to' => 'getUpdateTo', + 'orders' => 'getOrders', + 'statuses' => 'getStatuses', + 'has_cis' => 'getHasCis' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('update_from', $data ?? [], null); + $this->setIfExists('update_to', $data ?? [], null); + $this->setIfExists('orders', $data ?? [], null); + $this->setIfExists('statuses', $data ?? [], null); + $this->setIfExists('has_cis', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets date_from + * + * @return \DateTime|null + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime|null $date_from Начальная дата, когда заказ был сформирован. Формат даты: `ГГГГ‑ММ‑ДД`. Нельзя использовать вместе с параметрами `updateFrom` и `updateTo`. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime|null + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime|null $date_to Конечная дата, когда заказ был сформирован. Формат даты: `ГГГГ‑ММ‑ДД`. Нельзя использовать вместе с параметрами `updateFrom` и `updateTo`. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets update_from + * + * @return \DateTime|null + */ + public function getUpdateFrom() + { + return $this->container['update_from']; + } + + /** + * Sets update_from + * + * @param \DateTime|null $update_from Начальная дата периода, за который были изменения статуса заказа. Формат даты: `ГГГГ‑ММ‑ДД`. Нельзя использовать вместе с параметрами `dateFrom` и `dateTo`. + * + * @return self + */ + public function setUpdateFrom($update_from) + { + if (is_null($update_from)) { + throw new \InvalidArgumentException('non-nullable update_from cannot be null'); + } + $this->container['update_from'] = $update_from; + + return $this; + } + + /** + * Gets update_to + * + * @return \DateTime|null + */ + public function getUpdateTo() + { + return $this->container['update_to']; + } + + /** + * Sets update_to + * + * @param \DateTime|null $update_to Конечная дата периода, за который были изменения статуса заказа. Формат даты: `ГГГГ‑ММ‑ДД`. Нельзя использовать вместе с параметрами `dateFrom` и `dateTo`. + * + * @return self + */ + public function setUpdateTo($update_to) + { + if (is_null($update_to)) { + throw new \InvalidArgumentException('non-nullable update_to cannot be null'); + } + $this->container['update_to'] = $update_to; + + return $this; + } + + /** + * Gets orders + * + * @return int[]|null + */ + public function getOrders() + { + return $this->container['orders']; + } + + /** + * Sets orders + * + * @param int[]|null $orders Список идентификаторов заказов. + * + * @return self + */ + public function setOrders($orders) + { + if (is_null($orders)) { + array_push($this->openAPINullablesSetToNull, 'orders'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('orders', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['orders'] = $orders; + + return $this; + } + + /** + * Gets statuses + * + * @return \OpenAPI\Client\Model\OrderStatsStatusType[]|null + */ + public function getStatuses() + { + return $this->container['statuses']; + } + + /** + * Sets statuses + * + * @param \OpenAPI\Client\Model\OrderStatsStatusType[]|null $statuses Список статусов заказов. + * + * @return self + */ + public function setStatuses($statuses) + { + if (is_null($statuses)) { + array_push($this->openAPINullablesSetToNull, 'statuses'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('statuses', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['statuses'] = $statuses; + + return $this; + } + + /** + * Gets has_cis + * + * @return bool|null + */ + public function getHasCis() + { + return $this->container['has_cis']; + } + + /** + * Sets has_cis + * + * @param bool|null $has_cis Нужно ли вернуть только те заказы, в составе которых есть хотя бы один товар с кодом идентификации [в системе «Честный ЗНАК»](https://честныйзнак.рф/): * `true` — да. * `false` — нет. Такие коды присваиваются товарам, которые подлежат маркировке и относятся к определенным категориям. + * + * @return self + */ + public function setHasCis($has_cis) + { + if (is_null($has_cis)) { + throw new \InvalidArgumentException('non-nullable has_cis cannot be null'); + } + $this->container['has_cis'] = $has_cis; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOrdersStatsResponse.php b/erp24/lib/yandex_market_api/Model/GetOrdersStatsResponse.php new file mode 100644 index 00000000..e0bf0280 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOrdersStatsResponse.php @@ -0,0 +1,444 @@ + + */ +class GetOrdersStatsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOrdersStatsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OrdersStatsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OrdersStatsDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OrdersStatsDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOutletLicensesResponse.php b/erp24/lib/yandex_market_api/Model/GetOutletLicensesResponse.php new file mode 100644 index 00000000..22479ed8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOutletLicensesResponse.php @@ -0,0 +1,443 @@ + + */ +class GetOutletLicensesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOutletLicensesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OutletLicensesResponseDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OutletLicensesResponseDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OutletLicensesResponseDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOutletResponse.php b/erp24/lib/yandex_market_api/Model/GetOutletResponse.php new file mode 100644 index 00000000..89c53ccc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOutletResponse.php @@ -0,0 +1,410 @@ + + */ +class GetOutletResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOutletResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'outlet' => '\OpenAPI\Client\Model\FullOutletDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'outlet' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'outlet' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'outlet' => 'outlet' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'outlet' => 'setOutlet' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'outlet' => 'getOutlet' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('outlet', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets outlet + * + * @return \OpenAPI\Client\Model\FullOutletDTO|null + */ + public function getOutlet() + { + return $this->container['outlet']; + } + + /** + * Sets outlet + * + * @param \OpenAPI\Client\Model\FullOutletDTO|null $outlet outlet + * + * @return self + */ + public function setOutlet($outlet) + { + if (is_null($outlet)) { + throw new \InvalidArgumentException('non-nullable outlet cannot be null'); + } + $this->container['outlet'] = $outlet; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetOutletsResponse.php b/erp24/lib/yandex_market_api/Model/GetOutletsResponse.php new file mode 100644 index 00000000..dda0489e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetOutletsResponse.php @@ -0,0 +1,481 @@ + + */ +class GetOutletsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetOutletsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'outlets' => '\OpenAPI\Client\Model\FullOutletDTO[]', + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'pager' => '\OpenAPI\Client\Model\FlippingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'outlets' => null, + 'paging' => null, + 'pager' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'outlets' => false, + 'paging' => false, + 'pager' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'outlets' => 'outlets', + 'paging' => 'paging', + 'pager' => 'pager' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'outlets' => 'setOutlets', + 'paging' => 'setPaging', + 'pager' => 'setPager' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'outlets' => 'getOutlets', + 'paging' => 'getPaging', + 'pager' => 'getPager' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('outlets', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('pager', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['outlets'] === null) { + $invalidProperties[] = "'outlets' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets outlets + * + * @return \OpenAPI\Client\Model\FullOutletDTO[] + */ + public function getOutlets() + { + return $this->container['outlets']; + } + + /** + * Sets outlets + * + * @param \OpenAPI\Client\Model\FullOutletDTO[] $outlets Информация о точках продаж. + * + * @return self + */ + public function setOutlets($outlets) + { + if (is_null($outlets)) { + throw new \InvalidArgumentException('non-nullable outlets cannot be null'); + } + $this->container['outlets'] = $outlets; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets pager + * + * @return \OpenAPI\Client\Model\FlippingPagerDTO|null + */ + public function getPager() + { + return $this->container['pager']; + } + + /** + * Sets pager + * + * @param \OpenAPI\Client\Model\FlippingPagerDTO|null $pager pager + * + * @return self + */ + public function setPager($pager) + { + if (is_null($pager)) { + throw new \InvalidArgumentException('non-nullable pager cannot be null'); + } + $this->container['pager'] = $pager; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPriceDTO.php b/erp24/lib/yandex_market_api/Model/GetPriceDTO.php new file mode 100644 index 00000000..c37e0dbc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPriceDTO.php @@ -0,0 +1,496 @@ + + */ +class GetPriceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPriceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'float', + 'currency_id' => '\OpenAPI\Client\Model\CurrencyType', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'currency_id' => null, + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'value' => false, + 'currency_id' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'currency_id' => 'currencyId', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'currency_id' => 'setCurrencyId', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'currency_id' => 'getCurrencyId', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('currency_id', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if (($this->container['value'] <= 0)) { + $invalidProperties[] = "invalid value for 'value', must be bigger than 0."; + } + + if ($this->container['currency_id'] === null) { + $invalidProperties[] = "'currency_id' can't be null"; + } + if ($this->container['updated_at'] === null) { + $invalidProperties[] = "'updated_at' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return float + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param float $value Значение. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + + if (($value <= 0)) { + throw new \InvalidArgumentException('invalid value for $value when calling GetPriceDTO., must be bigger than 0.'); + } + + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets currency_id + * + * @return \OpenAPI\Client\Model\CurrencyType + */ + public function getCurrencyId() + { + return $this->container['currency_id']; + } + + /** + * Sets currency_id + * + * @param \OpenAPI\Client\Model\CurrencyType $currency_id currency_id + * + * @return self + */ + public function setCurrencyId($currency_id) + { + if (is_null($currency_id)) { + throw new \InvalidArgumentException('non-nullable currency_id cannot be null'); + } + $this->container['currency_id'] = $currency_id; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime $updated_at Время последнего обновления. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPriceWithDiscountDTO.php b/erp24/lib/yandex_market_api/Model/GetPriceWithDiscountDTO.php new file mode 100644 index 00000000..11276ac2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPriceWithDiscountDTO.php @@ -0,0 +1,539 @@ + + */ +class GetPriceWithDiscountDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPriceWithDiscountDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'float', + 'currency_id' => '\OpenAPI\Client\Model\CurrencyType', + 'discount_base' => 'float', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'currency_id' => null, + 'discount_base' => null, + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'value' => false, + 'currency_id' => false, + 'discount_base' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'currency_id' => 'currencyId', + 'discount_base' => 'discountBase', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'currency_id' => 'setCurrencyId', + 'discount_base' => 'setDiscountBase', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'currency_id' => 'getCurrencyId', + 'discount_base' => 'getDiscountBase', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('currency_id', $data ?? [], null); + $this->setIfExists('discount_base', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if (($this->container['value'] <= 0)) { + $invalidProperties[] = "invalid value for 'value', must be bigger than 0."; + } + + if ($this->container['currency_id'] === null) { + $invalidProperties[] = "'currency_id' can't be null"; + } + if (!is_null($this->container['discount_base']) && ($this->container['discount_base'] <= 0)) { + $invalidProperties[] = "invalid value for 'discount_base', must be bigger than 0."; + } + + if ($this->container['updated_at'] === null) { + $invalidProperties[] = "'updated_at' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return float + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param float $value Значение. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + + if (($value <= 0)) { + throw new \InvalidArgumentException('invalid value for $value when calling GetPriceWithDiscountDTO., must be bigger than 0.'); + } + + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets currency_id + * + * @return \OpenAPI\Client\Model\CurrencyType + */ + public function getCurrencyId() + { + return $this->container['currency_id']; + } + + /** + * Sets currency_id + * + * @param \OpenAPI\Client\Model\CurrencyType $currency_id currency_id + * + * @return self + */ + public function setCurrencyId($currency_id) + { + if (is_null($currency_id)) { + throw new \InvalidArgumentException('non-nullable currency_id cannot be null'); + } + $this->container['currency_id'] = $currency_id; + + return $this; + } + + /** + * Gets discount_base + * + * @return float|null + */ + public function getDiscountBase() + { + return $this->container['discount_base']; + } + + /** + * Sets discount_base + * + * @param float|null $discount_base Цена до скидки. Число должно быть целым. Вы можете указать цену со скидкой от 5 до 99%. Передавайте этот параметр при каждом обновлении цены, если предоставляете скидку на товар. + * + * @return self + */ + public function setDiscountBase($discount_base) + { + if (is_null($discount_base)) { + throw new \InvalidArgumentException('non-nullable discount_base cannot be null'); + } + + if (($discount_base <= 0)) { + throw new \InvalidArgumentException('invalid value for $discount_base when calling GetPriceWithDiscountDTO., must be bigger than 0.'); + } + + $this->container['discount_base'] = $discount_base; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime $updated_at Время последнего обновления. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPriceWithVatDTO.php b/erp24/lib/yandex_market_api/Model/GetPriceWithVatDTO.php new file mode 100644 index 00000000..282ddd52 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPriceWithVatDTO.php @@ -0,0 +1,549 @@ + + */ +class GetPriceWithVatDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPriceWithVatDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'float', + 'discount_base' => 'float', + 'currency_id' => '\OpenAPI\Client\Model\CurrencyType', + 'vat' => 'int', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'discount_base' => null, + 'currency_id' => null, + 'vat' => 'int32', + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'value' => false, + 'discount_base' => false, + 'currency_id' => false, + 'vat' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'discount_base' => 'discountBase', + 'currency_id' => 'currencyId', + 'vat' => 'vat', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'discount_base' => 'setDiscountBase', + 'currency_id' => 'setCurrencyId', + 'vat' => 'setVat', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'discount_base' => 'getDiscountBase', + 'currency_id' => 'getCurrencyId', + 'vat' => 'getVat', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('discount_base', $data ?? [], null); + $this->setIfExists('currency_id', $data ?? [], null); + $this->setIfExists('vat', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['updated_at'] === null) { + $invalidProperties[] = "'updated_at' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return float|null + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param float|null $value Цена на товар. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets discount_base + * + * @return float|null + */ + public function getDiscountBase() + { + return $this->container['discount_base']; + } + + /** + * Sets discount_base + * + * @param float|null $discount_base Цена на товар без скидки. Число должно быть целым. Вы можете указать цену со скидкой от 5 до 99%. Передавайте этот параметр при каждом обновлении цены, если предоставляете скидку на товар. + * + * @return self + */ + public function setDiscountBase($discount_base) + { + if (is_null($discount_base)) { + throw new \InvalidArgumentException('non-nullable discount_base cannot be null'); + } + $this->container['discount_base'] = $discount_base; + + return $this; + } + + /** + * Gets currency_id + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrencyId() + { + return $this->container['currency_id']; + } + + /** + * Sets currency_id + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency_id currency_id + * + * @return self + */ + public function setCurrencyId($currency_id) + { + if (is_null($currency_id)) { + throw new \InvalidArgumentException('non-nullable currency_id cannot be null'); + } + $this->container['currency_id'] = $currency_id; + + return $this; + } + + /** + * Gets vat + * + * @return int|null + */ + public function getVat() + { + return $this->container['vat']; + } + + /** + * Sets vat + * + * @param int|null $vat Идентификатор ставки НДС, применяемой для товара: * `2` — 10%. * `5` — 0%. * `6` — не облагается НДС. * `7` — 20%. Если параметр не указан, используется ставка НДС, установленная в кабинете. + * + * @return self + */ + public function setVat($vat) + { + if (is_null($vat)) { + throw new \InvalidArgumentException('non-nullable vat cannot be null'); + } + $this->container['vat'] = $vat; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime $updated_at Время последнего обновления. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPricesByOfferIdsRequest.php b/erp24/lib/yandex_market_api/Model/GetPricesByOfferIdsRequest.php new file mode 100644 index 00000000..1624c680 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPricesByOfferIdsRequest.php @@ -0,0 +1,432 @@ + + */ +class GetPricesByOfferIdsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPricesByOfferIdsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) > 2000)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 2000."; + } + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[]|null + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[]|null $offer_ids Список SKU. {% note warning \"Такой список возвращается только целиком\" %} Если вы запрашиваете информацию по конкретным SKU, не заполняйте: * `page_token` * `limit` {% endnote %}   + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($offer_ids) && (count($offer_ids) > 2000)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling GetPricesByOfferIdsRequest., number of items must be less than or equal to 2000.'); + } + if (!is_null($offer_ids) && (count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling GetPricesByOfferIdsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPricesByOfferIdsResponse.php b/erp24/lib/yandex_market_api/Model/GetPricesByOfferIdsResponse.php new file mode 100644 index 00000000..4f4b0ef9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPricesByOfferIdsResponse.php @@ -0,0 +1,444 @@ + + */ +class GetPricesByOfferIdsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPricesByOfferIdsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OfferPriceByOfferIdsListResponseDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OfferPriceByOfferIdsListResponseDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OfferPriceByOfferIdsListResponseDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPricesResponse.php b/erp24/lib/yandex_market_api/Model/GetPricesResponse.php new file mode 100644 index 00000000..e0c73751 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPricesResponse.php @@ -0,0 +1,444 @@ + + */ +class GetPricesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPricesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OfferPriceListResponseDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OfferPriceListResponseDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OfferPriceListResponseDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoAssortmentInfoDTO.php b/erp24/lib/yandex_market_api/Model/GetPromoAssortmentInfoDTO.php new file mode 100644 index 00000000..3dad78f4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoAssortmentInfoDTO.php @@ -0,0 +1,481 @@ + + */ +class GetPromoAssortmentInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoAssortmentInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'active_offers' => 'int', + 'potential_offers' => 'int', + 'processing' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'active_offers' => 'int32', + 'potential_offers' => 'int32', + 'processing' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'active_offers' => false, + 'potential_offers' => false, + 'processing' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'active_offers' => 'activeOffers', + 'potential_offers' => 'potentialOffers', + 'processing' => 'processing' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'active_offers' => 'setActiveOffers', + 'potential_offers' => 'setPotentialOffers', + 'processing' => 'setProcessing' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'active_offers' => 'getActiveOffers', + 'potential_offers' => 'getPotentialOffers', + 'processing' => 'getProcessing' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('active_offers', $data ?? [], null); + $this->setIfExists('potential_offers', $data ?? [], null); + $this->setIfExists('processing', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['active_offers'] === null) { + $invalidProperties[] = "'active_offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets active_offers + * + * @return int + */ + public function getActiveOffers() + { + return $this->container['active_offers']; + } + + /** + * Sets active_offers + * + * @param int $active_offers Количество товаров, которые участвуют или участвовали в акции. Учитываются только товары, которые были добавлены вручную. Об автоматическом и ручном добавлении товаров в акцию читайте [в Справке Маркета для продавцов](https://yandex.ru/support2/marketplace/ru/marketing/promos/market/index). + * + * @return self + */ + public function setActiveOffers($active_offers) + { + if (is_null($active_offers)) { + throw new \InvalidArgumentException('non-nullable active_offers cannot be null'); + } + $this->container['active_offers'] = $active_offers; + + return $this; + } + + /** + * Gets potential_offers + * + * @return int|null + */ + public function getPotentialOffers() + { + return $this->container['potential_offers']; + } + + /** + * Sets potential_offers + * + * @param int|null $potential_offers Количество доступных товаров в акции. Параметр возвращается только для текущих и будущих акций. + * + * @return self + */ + public function setPotentialOffers($potential_offers) + { + if (is_null($potential_offers)) { + throw new \InvalidArgumentException('non-nullable potential_offers cannot be null'); + } + $this->container['potential_offers'] = $potential_offers; + + return $this; + } + + /** + * Gets processing + * + * @return bool|null + */ + public function getProcessing() + { + return $this->container['processing']; + } + + /** + * Sets processing + * + * @param bool|null $processing Есть ли изменения в ассортименте, которые еще не применились. Сохранение изменений занимает некоторое время. Параметр возвращается только для текущих и будущих акций. + * + * @return self + */ + public function setProcessing($processing) + { + if (is_null($processing)) { + throw new \InvalidArgumentException('non-nullable processing cannot be null'); + } + $this->container['processing'] = $processing; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoBestsellerInfoDTO.php b/erp24/lib/yandex_market_api/Model/GetPromoBestsellerInfoDTO.php new file mode 100644 index 00000000..f53e5a74 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoBestsellerInfoDTO.php @@ -0,0 +1,447 @@ + + */ +class GetPromoBestsellerInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoBestsellerInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bestseller' => 'bool', + 'entry_deadline' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bestseller' => null, + 'entry_deadline' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bestseller' => false, + 'entry_deadline' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bestseller' => 'bestseller', + 'entry_deadline' => 'entryDeadline' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bestseller' => 'setBestseller', + 'entry_deadline' => 'setEntryDeadline' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bestseller' => 'getBestseller', + 'entry_deadline' => 'getEntryDeadline' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('bestseller', $data ?? [], null); + $this->setIfExists('entry_deadline', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['bestseller'] === null) { + $invalidProperties[] = "'bestseller' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets bestseller + * + * @return bool + */ + public function getBestseller() + { + return $this->container['bestseller']; + } + + /** + * Sets bestseller + * + * @param bool $bestseller Является ли акция «Бестселлером Маркета». Подробнее об этой акции читайте [в Справке Маркета для продавцов](https://yandex.ru/support2/marketplace/ru/marketing/promos/market/bestsellers). + * + * @return self + */ + public function setBestseller($bestseller) + { + if (is_null($bestseller)) { + throw new \InvalidArgumentException('non-nullable bestseller cannot be null'); + } + $this->container['bestseller'] = $bestseller; + + return $this; + } + + /** + * Gets entry_deadline + * + * @return \DateTime|null + */ + public function getEntryDeadline() + { + return $this->container['entry_deadline']; + } + + /** + * Sets entry_deadline + * + * @param \DateTime|null $entry_deadline До какой даты можно добавить товар в акцию «Бестселлеры Маркета». Параметр возвращается только для текущих и будущих акций «Бестселлеры Маркета». + * + * @return self + */ + public function setEntryDeadline($entry_deadline) + { + if (is_null($entry_deadline)) { + throw new \InvalidArgumentException('non-nullable entry_deadline cannot be null'); + } + $this->container['entry_deadline'] = $entry_deadline; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoConstraintsDTO.php b/erp24/lib/yandex_market_api/Model/GetPromoConstraintsDTO.php new file mode 100644 index 00000000..d4130cdb --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoConstraintsDTO.php @@ -0,0 +1,417 @@ + + */ +class GetPromoConstraintsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoConstraintsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'warehouse_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'warehouse_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'warehouse_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'warehouse_ids' => 'warehouseIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'warehouse_ids' => 'setWarehouseIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'warehouse_ids' => 'getWarehouseIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('warehouse_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets warehouse_ids + * + * @return int[]|null + */ + public function getWarehouseIds() + { + return $this->container['warehouse_ids']; + } + + /** + * Sets warehouse_ids + * + * @param int[]|null $warehouse_ids Идентификаторы складов, для которых действует акция. Товары, которые лежат на других складах, не будут продаваться по акции. Параметр возвращается, только если в условиях акции есть ограничение по складу. + * + * @return self + */ + public function setWarehouseIds($warehouse_ids) + { + if (is_null($warehouse_ids)) { + array_push($this->openAPINullablesSetToNull, 'warehouse_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('warehouse_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['warehouse_ids'] = $warehouse_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoDTO.php b/erp24/lib/yandex_market_api/Model/GetPromoDTO.php new file mode 100644 index 00000000..b6a1ec5d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoDTO.php @@ -0,0 +1,710 @@ + + */ +class GetPromoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'name' => 'string', + 'period' => '\OpenAPI\Client\Model\PromoPeriodDTO', + 'participating' => 'bool', + 'assortment_info' => '\OpenAPI\Client\Model\GetPromoAssortmentInfoDTO', + 'mechanics_info' => '\OpenAPI\Client\Model\GetPromoMechanicsInfoDTO', + 'bestseller_info' => '\OpenAPI\Client\Model\GetPromoBestsellerInfoDTO', + 'channels' => '\OpenAPI\Client\Model\ChannelType[]', + 'constraints' => '\OpenAPI\Client\Model\GetPromoConstraintsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'name' => null, + 'period' => null, + 'participating' => null, + 'assortment_info' => null, + 'mechanics_info' => null, + 'bestseller_info' => null, + 'channels' => null, + 'constraints' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'period' => false, + 'participating' => false, + 'assortment_info' => false, + 'mechanics_info' => false, + 'bestseller_info' => false, + 'channels' => true, + 'constraints' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'period' => 'period', + 'participating' => 'participating', + 'assortment_info' => 'assortmentInfo', + 'mechanics_info' => 'mechanicsInfo', + 'bestseller_info' => 'bestsellerInfo', + 'channels' => 'channels', + 'constraints' => 'constraints' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'period' => 'setPeriod', + 'participating' => 'setParticipating', + 'assortment_info' => 'setAssortmentInfo', + 'mechanics_info' => 'setMechanicsInfo', + 'bestseller_info' => 'setBestsellerInfo', + 'channels' => 'setChannels', + 'constraints' => 'setConstraints' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'period' => 'getPeriod', + 'participating' => 'getParticipating', + 'assortment_info' => 'getAssortmentInfo', + 'mechanics_info' => 'getMechanicsInfo', + 'bestseller_info' => 'getBestsellerInfo', + 'channels' => 'getChannels', + 'constraints' => 'getConstraints' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('period', $data ?? [], null); + $this->setIfExists('participating', $data ?? [], null); + $this->setIfExists('assortment_info', $data ?? [], null); + $this->setIfExists('mechanics_info', $data ?? [], null); + $this->setIfExists('bestseller_info', $data ?? [], null); + $this->setIfExists('channels', $data ?? [], null); + $this->setIfExists('constraints', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['period'] === null) { + $invalidProperties[] = "'period' can't be null"; + } + if ($this->container['participating'] === null) { + $invalidProperties[] = "'participating' can't be null"; + } + if ($this->container['assortment_info'] === null) { + $invalidProperties[] = "'assortment_info' can't be null"; + } + if ($this->container['mechanics_info'] === null) { + $invalidProperties[] = "'mechanics_info' can't be null"; + } + if ($this->container['bestseller_info'] === null) { + $invalidProperties[] = "'bestseller_info' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id Идентификатор акции. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название акции. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets period + * + * @return \OpenAPI\Client\Model\PromoPeriodDTO + */ + public function getPeriod() + { + return $this->container['period']; + } + + /** + * Sets period + * + * @param \OpenAPI\Client\Model\PromoPeriodDTO $period period + * + * @return self + */ + public function setPeriod($period) + { + if (is_null($period)) { + throw new \InvalidArgumentException('non-nullable period cannot be null'); + } + $this->container['period'] = $period; + + return $this; + } + + /** + * Gets participating + * + * @return bool + */ + public function getParticipating() + { + return $this->container['participating']; + } + + /** + * Sets participating + * + * @param bool $participating Участвует или участвовал ли продавец в этой акции. Для текущих и будущих акций возвращается со значением `true`, если в акции есть товары, которые были добавлены вручную. Если товары не участвуют в акции или добавлены в нее автоматически, параметр возвращается со значением `false`. Для прошедших акций всегда возвращается со значением `true`. Об автоматическом и ручном добавлении товаров в акцию читайте [в Справке Маркета для продавцов](https://yandex.ru/support2/marketplace/ru/marketing/promos/market/index). + * + * @return self + */ + public function setParticipating($participating) + { + if (is_null($participating)) { + throw new \InvalidArgumentException('non-nullable participating cannot be null'); + } + $this->container['participating'] = $participating; + + return $this; + } + + /** + * Gets assortment_info + * + * @return \OpenAPI\Client\Model\GetPromoAssortmentInfoDTO + */ + public function getAssortmentInfo() + { + return $this->container['assortment_info']; + } + + /** + * Sets assortment_info + * + * @param \OpenAPI\Client\Model\GetPromoAssortmentInfoDTO $assortment_info assortment_info + * + * @return self + */ + public function setAssortmentInfo($assortment_info) + { + if (is_null($assortment_info)) { + throw new \InvalidArgumentException('non-nullable assortment_info cannot be null'); + } + $this->container['assortment_info'] = $assortment_info; + + return $this; + } + + /** + * Gets mechanics_info + * + * @return \OpenAPI\Client\Model\GetPromoMechanicsInfoDTO + */ + public function getMechanicsInfo() + { + return $this->container['mechanics_info']; + } + + /** + * Sets mechanics_info + * + * @param \OpenAPI\Client\Model\GetPromoMechanicsInfoDTO $mechanics_info mechanics_info + * + * @return self + */ + public function setMechanicsInfo($mechanics_info) + { + if (is_null($mechanics_info)) { + throw new \InvalidArgumentException('non-nullable mechanics_info cannot be null'); + } + $this->container['mechanics_info'] = $mechanics_info; + + return $this; + } + + /** + * Gets bestseller_info + * + * @return \OpenAPI\Client\Model\GetPromoBestsellerInfoDTO + */ + public function getBestsellerInfo() + { + return $this->container['bestseller_info']; + } + + /** + * Sets bestseller_info + * + * @param \OpenAPI\Client\Model\GetPromoBestsellerInfoDTO $bestseller_info bestseller_info + * + * @return self + */ + public function setBestsellerInfo($bestseller_info) + { + if (is_null($bestseller_info)) { + throw new \InvalidArgumentException('non-nullable bestseller_info cannot be null'); + } + $this->container['bestseller_info'] = $bestseller_info; + + return $this; + } + + /** + * Gets channels + * + * @return \OpenAPI\Client\Model\ChannelType[]|null + */ + public function getChannels() + { + return $this->container['channels']; + } + + /** + * Sets channels + * + * @param \OpenAPI\Client\Model\ChannelType[]|null $channels Список каналов продвижения товаров. + * + * @return self + */ + public function setChannels($channels) + { + if (is_null($channels)) { + array_push($this->openAPINullablesSetToNull, 'channels'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('channels', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['channels'] = $channels; + + return $this; + } + + /** + * Gets constraints + * + * @return \OpenAPI\Client\Model\GetPromoConstraintsDTO|null + */ + public function getConstraints() + { + return $this->container['constraints']; + } + + /** + * Sets constraints + * + * @param \OpenAPI\Client\Model\GetPromoConstraintsDTO|null $constraints constraints + * + * @return self + */ + public function setConstraints($constraints) + { + if (is_null($constraints)) { + throw new \InvalidArgumentException('non-nullable constraints cannot be null'); + } + $this->container['constraints'] = $constraints; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoMechanicsInfoDTO.php b/erp24/lib/yandex_market_api/Model/GetPromoMechanicsInfoDTO.php new file mode 100644 index 00000000..a09179b0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoMechanicsInfoDTO.php @@ -0,0 +1,447 @@ + + */ +class GetPromoMechanicsInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoMechanicsInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\MechanicsType', + 'promocode_info' => '\OpenAPI\Client\Model\GetPromoPromocodeInfoDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'promocode_info' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'promocode_info' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'promocode_info' => 'promocodeInfo' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'promocode_info' => 'setPromocodeInfo' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'promocode_info' => 'getPromocodeInfo' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('promocode_info', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\MechanicsType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\MechanicsType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets promocode_info + * + * @return \OpenAPI\Client\Model\GetPromoPromocodeInfoDTO|null + */ + public function getPromocodeInfo() + { + return $this->container['promocode_info']; + } + + /** + * Sets promocode_info + * + * @param \OpenAPI\Client\Model\GetPromoPromocodeInfoDTO|null $promocode_info promocode_info + * + * @return self + */ + public function setPromocodeInfo($promocode_info) + { + if (is_null($promocode_info)) { + throw new \InvalidArgumentException('non-nullable promocode_info cannot be null'); + } + $this->container['promocode_info'] = $promocode_info; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoOfferDTO.php b/erp24/lib/yandex_market_api/Model/GetPromoOfferDTO.php new file mode 100644 index 00000000..4abda469 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoOfferDTO.php @@ -0,0 +1,543 @@ + + */ +class GetPromoOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'status' => '\OpenAPI\Client\Model\PromoOfferParticipationStatusType', + 'params' => '\OpenAPI\Client\Model\PromoOfferParamsDTO', + 'auto_participating_details' => '\OpenAPI\Client\Model\PromoOfferAutoParticipatingDetailsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'status' => null, + 'params' => null, + 'auto_participating_details' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'status' => false, + 'params' => false, + 'auto_participating_details' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'status' => 'status', + 'params' => 'params', + 'auto_participating_details' => 'autoParticipatingDetails' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'status' => 'setStatus', + 'params' => 'setParams', + 'auto_participating_details' => 'setAutoParticipatingDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'status' => 'getStatus', + 'params' => 'getParams', + 'auto_participating_details' => 'getAutoParticipatingDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('params', $data ?? [], null); + $this->setIfExists('auto_participating_details', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + if ($this->container['params'] === null) { + $invalidProperties[] = "'params' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling GetPromoOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling GetPromoOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling GetPromoOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\PromoOfferParticipationStatusType + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\PromoOfferParticipationStatusType $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets params + * + * @return \OpenAPI\Client\Model\PromoOfferParamsDTO + */ + public function getParams() + { + return $this->container['params']; + } + + /** + * Sets params + * + * @param \OpenAPI\Client\Model\PromoOfferParamsDTO $params params + * + * @return self + */ + public function setParams($params) + { + if (is_null($params)) { + throw new \InvalidArgumentException('non-nullable params cannot be null'); + } + $this->container['params'] = $params; + + return $this; + } + + /** + * Gets auto_participating_details + * + * @return \OpenAPI\Client\Model\PromoOfferAutoParticipatingDetailsDTO|null + */ + public function getAutoParticipatingDetails() + { + return $this->container['auto_participating_details']; + } + + /** + * Sets auto_participating_details + * + * @param \OpenAPI\Client\Model\PromoOfferAutoParticipatingDetailsDTO|null $auto_participating_details auto_participating_details + * + * @return self + */ + public function setAutoParticipatingDetails($auto_participating_details) + { + if (is_null($auto_participating_details)) { + throw new \InvalidArgumentException('non-nullable auto_participating_details cannot be null'); + } + $this->container['auto_participating_details'] = $auto_participating_details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoOffersRequest.php b/erp24/lib/yandex_market_api/Model/GetPromoOffersRequest.php new file mode 100644 index 00000000..708f8e8a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoOffersRequest.php @@ -0,0 +1,447 @@ + + */ +class GetPromoOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'promo_id' => 'string', + 'status_type' => '\OpenAPI\Client\Model\PromoOfferParticipationStatusFilterType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'promo_id' => null, + 'status_type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'promo_id' => false, + 'status_type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'promo_id' => 'promoId', + 'status_type' => 'statusType' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'promo_id' => 'setPromoId', + 'status_type' => 'setStatusType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'promo_id' => 'getPromoId', + 'status_type' => 'getStatusType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('promo_id', $data ?? [], null); + $this->setIfExists('status_type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['promo_id'] === null) { + $invalidProperties[] = "'promo_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets promo_id + * + * @return string + */ + public function getPromoId() + { + return $this->container['promo_id']; + } + + /** + * Sets promo_id + * + * @param string $promo_id Идентификатор акции. + * + * @return self + */ + public function setPromoId($promo_id) + { + if (is_null($promo_id)) { + throw new \InvalidArgumentException('non-nullable promo_id cannot be null'); + } + $this->container['promo_id'] = $promo_id; + + return $this; + } + + /** + * Gets status_type + * + * @return \OpenAPI\Client\Model\PromoOfferParticipationStatusFilterType|null + */ + public function getStatusType() + { + return $this->container['status_type']; + } + + /** + * Sets status_type + * + * @param \OpenAPI\Client\Model\PromoOfferParticipationStatusFilterType|null $status_type status_type + * + * @return self + */ + public function setStatusType($status_type) + { + if (is_null($status_type)) { + throw new \InvalidArgumentException('non-nullable status_type cannot be null'); + } + $this->container['status_type'] = $status_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoOffersResponse.php b/erp24/lib/yandex_market_api/Model/GetPromoOffersResponse.php new file mode 100644 index 00000000..9f91e27b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoOffersResponse.php @@ -0,0 +1,443 @@ + + */ +class GetPromoOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetPromoOffersResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetPromoOffersResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetPromoOffersResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoOffersResultDTO.php b/erp24/lib/yandex_market_api/Model/GetPromoOffersResultDTO.php new file mode 100644 index 00000000..3898f3e9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoOffersResultDTO.php @@ -0,0 +1,447 @@ + + */ +class GetPromoOffersResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoOffersResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\GetPromoOfferDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\GetPromoOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\GetPromoOfferDTO[] $offers Товары, которые участвуют или могут участвовать в акции. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromoPromocodeInfoDTO.php b/erp24/lib/yandex_market_api/Model/GetPromoPromocodeInfoDTO.php new file mode 100644 index 00000000..9a521284 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromoPromocodeInfoDTO.php @@ -0,0 +1,450 @@ + + */ +class GetPromoPromocodeInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromoPromocodeInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'promocode' => 'string', + 'discount' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'promocode' => null, + 'discount' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'promocode' => false, + 'discount' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'promocode' => 'promocode', + 'discount' => 'discount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'promocode' => 'setPromocode', + 'discount' => 'setDiscount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'promocode' => 'getPromocode', + 'discount' => 'getDiscount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('promocode', $data ?? [], null); + $this->setIfExists('discount', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['promocode'] === null) { + $invalidProperties[] = "'promocode' can't be null"; + } + if ($this->container['discount'] === null) { + $invalidProperties[] = "'discount' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets promocode + * + * @return string + */ + public function getPromocode() + { + return $this->container['promocode']; + } + + /** + * Sets promocode + * + * @param string $promocode Промокод. + * + * @return self + */ + public function setPromocode($promocode) + { + if (is_null($promocode)) { + throw new \InvalidArgumentException('non-nullable promocode cannot be null'); + } + $this->container['promocode'] = $promocode; + + return $this; + } + + /** + * Gets discount + * + * @return int + */ + public function getDiscount() + { + return $this->container['discount']; + } + + /** + * Sets discount + * + * @param int $discount Процент скидки по промокоду. + * + * @return self + */ + public function setDiscount($discount) + { + if (is_null($discount)) { + throw new \InvalidArgumentException('non-nullable discount cannot be null'); + } + $this->container['discount'] = $discount; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromosRequest.php b/erp24/lib/yandex_market_api/Model/GetPromosRequest.php new file mode 100644 index 00000000..faf1beff --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromosRequest.php @@ -0,0 +1,444 @@ + + */ +class GetPromosRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromosRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'participation' => '\OpenAPI\Client\Model\PromoParticipationType', + 'mechanics' => '\OpenAPI\Client\Model\MechanicsType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'participation' => null, + 'mechanics' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'participation' => false, + 'mechanics' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'participation' => 'participation', + 'mechanics' => 'mechanics' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'participation' => 'setParticipation', + 'mechanics' => 'setMechanics' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'participation' => 'getParticipation', + 'mechanics' => 'getMechanics' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('participation', $data ?? [], null); + $this->setIfExists('mechanics', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets participation + * + * @return \OpenAPI\Client\Model\PromoParticipationType|null + */ + public function getParticipation() + { + return $this->container['participation']; + } + + /** + * Sets participation + * + * @param \OpenAPI\Client\Model\PromoParticipationType|null $participation participation + * + * @return self + */ + public function setParticipation($participation) + { + if (is_null($participation)) { + throw new \InvalidArgumentException('non-nullable participation cannot be null'); + } + $this->container['participation'] = $participation; + + return $this; + } + + /** + * Gets mechanics + * + * @return \OpenAPI\Client\Model\MechanicsType|null + */ + public function getMechanics() + { + return $this->container['mechanics']; + } + + /** + * Sets mechanics + * + * @param \OpenAPI\Client\Model\MechanicsType|null $mechanics mechanics + * + * @return self + */ + public function setMechanics($mechanics) + { + if (is_null($mechanics)) { + throw new \InvalidArgumentException('non-nullable mechanics cannot be null'); + } + $this->container['mechanics'] = $mechanics; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromosResponse.php b/erp24/lib/yandex_market_api/Model/GetPromosResponse.php new file mode 100644 index 00000000..ebc1b0d0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromosResponse.php @@ -0,0 +1,443 @@ + + */ +class GetPromosResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromosResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetPromosResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetPromosResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetPromosResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetPromosResultDTO.php b/erp24/lib/yandex_market_api/Model/GetPromosResultDTO.php new file mode 100644 index 00000000..e789888c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetPromosResultDTO.php @@ -0,0 +1,413 @@ + + */ +class GetPromosResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetPromosResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'promos' => '\OpenAPI\Client\Model\GetPromoDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'promos' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'promos' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'promos' => 'promos' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'promos' => 'setPromos' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'promos' => 'getPromos' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('promos', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['promos'] === null) { + $invalidProperties[] = "'promos' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets promos + * + * @return \OpenAPI\Client\Model\GetPromoDTO[] + */ + public function getPromos() + { + return $this->container['promos']; + } + + /** + * Sets promos + * + * @param \OpenAPI\Client\Model\GetPromoDTO[] $promos Акции Маркета. + * + * @return self + */ + public function setPromos($promos) + { + if (is_null($promos)) { + throw new \InvalidArgumentException('non-nullable promos cannot be null'); + } + $this->container['promos'] = $promos; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetQualityRatingDetailsResponse.php b/erp24/lib/yandex_market_api/Model/GetQualityRatingDetailsResponse.php new file mode 100644 index 00000000..b8886398 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetQualityRatingDetailsResponse.php @@ -0,0 +1,443 @@ + + */ +class GetQualityRatingDetailsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetQualityRatingDetailsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\QualityRatingDetailsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\QualityRatingDetailsDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\QualityRatingDetailsDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetQualityRatingRequest.php b/erp24/lib/yandex_market_api/Model/GetQualityRatingRequest.php new file mode 100644 index 00000000..d95cf842 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetQualityRatingRequest.php @@ -0,0 +1,496 @@ + + */ +class GetQualityRatingRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetQualityRatingRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'campaign_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'date_from' => 'date', + 'date_to' => 'date', + 'campaign_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'date_from' => false, + 'date_to' => false, + 'campaign_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'campaign_ids' => 'campaignIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'campaign_ids' => 'setCampaignIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'campaign_ids' => 'getCampaignIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('campaign_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_ids'] === null) { + $invalidProperties[] = "'campaign_ids' can't be null"; + } + if ((count($this->container['campaign_ids']) > 50)) { + $invalidProperties[] = "invalid value for 'campaign_ids', number of items must be less than or equal to 50."; + } + + if ((count($this->container['campaign_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'campaign_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets date_from + * + * @return \DateTime|null + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime|null $date_from Начало периода. Формат даты: `ГГГГ‑ММ‑ДД`. Не может быть раньше 30 дней от текущей даты. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime|null + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime|null $date_to Конец периода. Формат даты: `ГГГГ‑ММ‑ДД`. Не может быть позже текущей даты. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets campaign_ids + * + * @return int[] + */ + public function getCampaignIds() + { + return $this->container['campaign_ids']; + } + + /** + * Sets campaign_ids + * + * @param int[] $campaign_ids Список идентификаторов магазинов. + * + * @return self + */ + public function setCampaignIds($campaign_ids) + { + if (is_null($campaign_ids)) { + throw new \InvalidArgumentException('non-nullable campaign_ids cannot be null'); + } + + if ((count($campaign_ids) > 50)) { + throw new \InvalidArgumentException('invalid value for $campaign_ids when calling GetQualityRatingRequest., number of items must be less than or equal to 50.'); + } + if ((count($campaign_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $campaign_ids when calling GetQualityRatingRequest., number of items must be greater than or equal to 1.'); + } + $this->container['campaign_ids'] = $campaign_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetQualityRatingResponse.php b/erp24/lib/yandex_market_api/Model/GetQualityRatingResponse.php new file mode 100644 index 00000000..f1e5b041 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetQualityRatingResponse.php @@ -0,0 +1,444 @@ + + */ +class GetQualityRatingResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetQualityRatingResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\CampaignsQualityRatingDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\CampaignsQualityRatingDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\CampaignsQualityRatingDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetQuarantineOffersRequest.php b/erp24/lib/yandex_market_api/Model/GetQuarantineOffersRequest.php new file mode 100644 index 00000000..e996846a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetQuarantineOffersRequest.php @@ -0,0 +1,632 @@ + + */ +class GetQuarantineOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetQuarantineOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_ids' => 'string[]', + 'card_statuses' => '\OpenAPI\Client\Model\OfferCardStatusType[]', + 'category_ids' => 'int[]', + 'vendor_names' => 'string[]', + 'tags' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_ids' => null, + 'card_statuses' => null, + 'category_ids' => null, + 'vendor_names' => null, + 'tags' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_ids' => true, + 'card_statuses' => true, + 'category_ids' => true, + 'vendor_names' => true, + 'tags' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_ids' => 'offerIds', + 'card_statuses' => 'cardStatuses', + 'category_ids' => 'categoryIds', + 'vendor_names' => 'vendorNames', + 'tags' => 'tags' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_ids' => 'setOfferIds', + 'card_statuses' => 'setCardStatuses', + 'category_ids' => 'setCategoryIds', + 'vendor_names' => 'setVendorNames', + 'tags' => 'setTags' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_ids' => 'getOfferIds', + 'card_statuses' => 'getCardStatuses', + 'category_ids' => 'getCategoryIds', + 'vendor_names' => 'getVendorNames', + 'tags' => 'getTags' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_ids', $data ?? [], null); + $this->setIfExists('card_statuses', $data ?? [], null); + $this->setIfExists('category_ids', $data ?? [], null); + $this->setIfExists('vendor_names', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) > 500)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 500."; + } + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['card_statuses']) && (count($this->container['card_statuses']) < 1)) { + $invalidProperties[] = "invalid value for 'card_statuses', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['category_ids']) && (count($this->container['category_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'category_ids', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['vendor_names']) && (count($this->container['vendor_names']) < 1)) { + $invalidProperties[] = "invalid value for 'vendor_names', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['tags']) && (count($this->container['tags']) < 1)) { + $invalidProperties[] = "invalid value for 'tags', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_ids + * + * @return string[]|null + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[]|null $offer_ids Идентификаторы товаров, информация о которых нужна.

                          ⚠️ Не используйте это поле одновременно с фильтрами по статусам карточек, категориям, брендам или тегам. Если вы хотите воспользоваться фильтрами, оставьте поле пустым. + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($offer_ids) && (count($offer_ids) > 500)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling GetQuarantineOffersRequest., number of items must be less than or equal to 500.'); + } + if (!is_null($offer_ids) && (count($offer_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_ids when calling GetQuarantineOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + + /** + * Gets card_statuses + * + * @return \OpenAPI\Client\Model\OfferCardStatusType[]|null + */ + public function getCardStatuses() + { + return $this->container['card_statuses']; + } + + /** + * Sets card_statuses + * + * @param \OpenAPI\Client\Model\OfferCardStatusType[]|null $card_statuses Фильтр по статусам карточек. [Что такое карточка товара](https://yandex.ru/support/marketplace/assortment/content/index.html) + * + * @return self + */ + public function setCardStatuses($card_statuses) + { + if (is_null($card_statuses)) { + array_push($this->openAPINullablesSetToNull, 'card_statuses'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('card_statuses', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($card_statuses) && (count($card_statuses) < 1)) { + throw new \InvalidArgumentException('invalid length for $card_statuses when calling GetQuarantineOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['card_statuses'] = $card_statuses; + + return $this; + } + + /** + * Gets category_ids + * + * @return int[]|null + */ + public function getCategoryIds() + { + return $this->container['category_ids']; + } + + /** + * Sets category_ids + * + * @param int[]|null $category_ids Фильтр по категориям на Маркете. + * + * @return self + */ + public function setCategoryIds($category_ids) + { + if (is_null($category_ids)) { + array_push($this->openAPINullablesSetToNull, 'category_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('category_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($category_ids) && (count($category_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $category_ids when calling GetQuarantineOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['category_ids'] = $category_ids; + + return $this; + } + + /** + * Gets vendor_names + * + * @return string[]|null + */ + public function getVendorNames() + { + return $this->container['vendor_names']; + } + + /** + * Sets vendor_names + * + * @param string[]|null $vendor_names Фильтр по брендам. + * + * @return self + */ + public function setVendorNames($vendor_names) + { + if (is_null($vendor_names)) { + array_push($this->openAPINullablesSetToNull, 'vendor_names'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('vendor_names', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($vendor_names) && (count($vendor_names) < 1)) { + throw new \InvalidArgumentException('invalid length for $vendor_names when calling GetQuarantineOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['vendor_names'] = $vendor_names; + + return $this; + } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Фильтр по тегам. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + array_push($this->openAPINullablesSetToNull, 'tags'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tags', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($tags) && (count($tags) < 1)) { + throw new \InvalidArgumentException('invalid length for $tags when calling GetQuarantineOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['tags'] = $tags; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetQuarantineOffersResponse.php b/erp24/lib/yandex_market_api/Model/GetQuarantineOffersResponse.php new file mode 100644 index 00000000..75bfd660 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetQuarantineOffersResponse.php @@ -0,0 +1,444 @@ + + */ +class GetQuarantineOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetQuarantineOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetQuarantineOffersResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetQuarantineOffersResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetQuarantineOffersResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetQuarantineOffersResultDTO.php b/erp24/lib/yandex_market_api/Model/GetQuarantineOffersResultDTO.php new file mode 100644 index 00000000..db7f38e3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetQuarantineOffersResultDTO.php @@ -0,0 +1,447 @@ + + */ +class GetQuarantineOffersResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetQuarantineOffersResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'offers' => '\OpenAPI\Client\Model\QuarantineOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\QuarantineOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\QuarantineOfferDTO[] $offers Страница списка товаров в карантине. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetRegionWithChildrenResponse.php b/erp24/lib/yandex_market_api/Model/GetRegionWithChildrenResponse.php new file mode 100644 index 00000000..6ece2ca5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetRegionWithChildrenResponse.php @@ -0,0 +1,443 @@ + + */ +class GetRegionWithChildrenResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetRegionWithChildrenResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'pager' => '\OpenAPI\Client\Model\FlippingPagerDTO', + 'regions' => '\OpenAPI\Client\Model\RegionDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'pager' => null, + 'regions' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'pager' => false, + 'regions' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'pager' => 'pager', + 'regions' => 'regions' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'pager' => 'setPager', + 'regions' => 'setRegions' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'pager' => 'getPager', + 'regions' => 'getRegions' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('pager', $data ?? [], null); + $this->setIfExists('regions', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets pager + * + * @return \OpenAPI\Client\Model\FlippingPagerDTO|null + */ + public function getPager() + { + return $this->container['pager']; + } + + /** + * Sets pager + * + * @param \OpenAPI\Client\Model\FlippingPagerDTO|null $pager pager + * + * @return self + */ + public function setPager($pager) + { + if (is_null($pager)) { + throw new \InvalidArgumentException('non-nullable pager cannot be null'); + } + $this->container['pager'] = $pager; + + return $this; + } + + /** + * Gets regions + * + * @return \OpenAPI\Client\Model\RegionDTO|null + */ + public function getRegions() + { + return $this->container['regions']; + } + + /** + * Sets regions + * + * @param \OpenAPI\Client\Model\RegionDTO|null $regions regions + * + * @return self + */ + public function setRegions($regions) + { + if (is_null($regions)) { + throw new \InvalidArgumentException('non-nullable regions cannot be null'); + } + $this->container['regions'] = $regions; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetRegionsResponse.php b/erp24/lib/yandex_market_api/Model/GetRegionsResponse.php new file mode 100644 index 00000000..3027c9ab --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetRegionsResponse.php @@ -0,0 +1,446 @@ + + */ +class GetRegionsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetRegionsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'regions' => '\OpenAPI\Client\Model\RegionDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'regions' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'regions' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'regions' => 'regions', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'regions' => 'setRegions', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'regions' => 'getRegions', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('regions', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['regions'] === null) { + $invalidProperties[] = "'regions' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets regions + * + * @return \OpenAPI\Client\Model\RegionDTO[] + */ + public function getRegions() + { + return $this->container['regions']; + } + + /** + * Sets regions + * + * @param \OpenAPI\Client\Model\RegionDTO[] $regions Регион доставки. + * + * @return self + */ + public function setRegions($regions) + { + if (is_null($regions)) { + throw new \InvalidArgumentException('non-nullable regions cannot be null'); + } + $this->container['regions'] = $regions; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetReportInfoResponse.php b/erp24/lib/yandex_market_api/Model/GetReportInfoResponse.php new file mode 100644 index 00000000..db0b154d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetReportInfoResponse.php @@ -0,0 +1,444 @@ + + */ +class GetReportInfoResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetReportInfoResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\ReportInfoDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\ReportInfoDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\ReportInfoDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetReturnResponse.php b/erp24/lib/yandex_market_api/Model/GetReturnResponse.php new file mode 100644 index 00000000..a48eba1b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetReturnResponse.php @@ -0,0 +1,443 @@ + + */ +class GetReturnResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetReturnResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\ReturnDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\ReturnDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\ReturnDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetReturnsResponse.php b/erp24/lib/yandex_market_api/Model/GetReturnsResponse.php new file mode 100644 index 00000000..c1d8b295 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetReturnsResponse.php @@ -0,0 +1,443 @@ + + */ +class GetReturnsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetReturnsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\PagedReturnsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\PagedReturnsDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\PagedReturnsDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetShipmentOrdersInfoResponse.php b/erp24/lib/yandex_market_api/Model/GetShipmentOrdersInfoResponse.php new file mode 100644 index 00000000..27d6004f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetShipmentOrdersInfoResponse.php @@ -0,0 +1,443 @@ + + */ +class GetShipmentOrdersInfoResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetShipmentOrdersInfoResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OrdersShipmentInfoDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OrdersShipmentInfoDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OrdersShipmentInfoDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetShipmentResponse.php b/erp24/lib/yandex_market_api/Model/GetShipmentResponse.php new file mode 100644 index 00000000..6cacd439 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetShipmentResponse.php @@ -0,0 +1,443 @@ + + */ +class GetShipmentResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetShipmentResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\ShipmentDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\ShipmentDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\ShipmentDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingEntriesRequest.php b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingEntriesRequest.php new file mode 100644 index 00000000..9163e1b7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingEntriesRequest.php @@ -0,0 +1,428 @@ + + */ +class GetSuggestedOfferMappingEntriesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetSuggestedOfferMappingEntriesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\MappingsOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + if ((count($this->container['offers']) > 500)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be less than or equal to 500."; + } + + if ((count($this->container['offers']) < 1)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\MappingsOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\MappingsOfferDTO[] $offers Список товаров. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + + if ((count($offers) > 500)) { + throw new \InvalidArgumentException('invalid value for $offers when calling GetSuggestedOfferMappingEntriesRequest., number of items must be less than or equal to 500.'); + } + if ((count($offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $offers when calling GetSuggestedOfferMappingEntriesRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingEntriesResponse.php b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingEntriesResponse.php new file mode 100644 index 00000000..d8e8fdee --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingEntriesResponse.php @@ -0,0 +1,444 @@ + + */ +class GetSuggestedOfferMappingEntriesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetSuggestedOfferMappingEntriesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OfferMappingSuggestionsListDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OfferMappingSuggestionsListDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OfferMappingSuggestionsListDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsRequest.php b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsRequest.php new file mode 100644 index 00000000..6a18c86d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsRequest.php @@ -0,0 +1,431 @@ + + */ +class GetSuggestedOfferMappingsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetSuggestedOfferMappingsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\SuggestedOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offers']) && (count($this->container['offers']) > 500)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be less than or equal to 500."; + } + + if (!is_null($this->container['offers']) && (count($this->container['offers']) < 1)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\SuggestedOfferDTO[]|null + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\SuggestedOfferDTO[]|null $offers Список товаров. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + array_push($this->openAPINullablesSetToNull, 'offers'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offers', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($offers) && (count($offers) > 500)) { + throw new \InvalidArgumentException('invalid value for $offers when calling GetSuggestedOfferMappingsRequest., number of items must be less than or equal to 500.'); + } + if (!is_null($offers) && (count($offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $offers when calling GetSuggestedOfferMappingsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsResponse.php b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsResponse.php new file mode 100644 index 00000000..52b4e4b7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsResponse.php @@ -0,0 +1,443 @@ + + */ +class GetSuggestedOfferMappingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetSuggestedOfferMappingsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetSuggestedOfferMappingsResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetSuggestedOfferMappingsResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetSuggestedOfferMappingsResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsResultDTO.php b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsResultDTO.php new file mode 100644 index 00000000..a68dce69 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetSuggestedOfferMappingsResultDTO.php @@ -0,0 +1,413 @@ + + */ +class GetSuggestedOfferMappingsResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetSuggestedOfferMappingsResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\SuggestedOfferMappingDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\SuggestedOfferMappingDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\SuggestedOfferMappingDTO[] $offers Список товаров. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetWarehouseStocksDTO.php b/erp24/lib/yandex_market_api/Model/GetWarehouseStocksDTO.php new file mode 100644 index 00000000..492a4029 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetWarehouseStocksDTO.php @@ -0,0 +1,447 @@ + + */ +class GetWarehouseStocksDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetWarehouseStocksDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'warehouses' => '\OpenAPI\Client\Model\WarehouseOffersDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'warehouses' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'warehouses' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'warehouses' => 'warehouses' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'warehouses' => 'setWarehouses' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'warehouses' => 'getWarehouses' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('warehouses', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['warehouses'] === null) { + $invalidProperties[] = "'warehouses' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets warehouses + * + * @return \OpenAPI\Client\Model\WarehouseOffersDTO[] + */ + public function getWarehouses() + { + return $this->container['warehouses']; + } + + /** + * Sets warehouses + * + * @param \OpenAPI\Client\Model\WarehouseOffersDTO[] $warehouses Страница списка складов. + * + * @return self + */ + public function setWarehouses($warehouses) + { + if (is_null($warehouses)) { + throw new \InvalidArgumentException('non-nullable warehouses cannot be null'); + } + $this->container['warehouses'] = $warehouses; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetWarehouseStocksRequest.php b/erp24/lib/yandex_market_api/Model/GetWarehouseStocksRequest.php new file mode 100644 index 00000000..b165dae2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetWarehouseStocksRequest.php @@ -0,0 +1,493 @@ + + */ +class GetWarehouseStocksRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetWarehouseStocksRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'with_turnover' => 'bool', + 'archived' => 'bool', + 'offer_ids' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'with_turnover' => null, + 'archived' => null, + 'offer_ids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'with_turnover' => false, + 'archived' => false, + 'offer_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'with_turnover' => 'withTurnover', + 'archived' => 'archived', + 'offer_ids' => 'offerIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'with_turnover' => 'setWithTurnover', + 'archived' => 'setArchived', + 'offer_ids' => 'setOfferIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'with_turnover' => 'getWithTurnover', + 'archived' => 'getArchived', + 'offer_ids' => 'getOfferIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('with_turnover', $data ?? [], false); + $this->setIfExists('archived', $data ?? [], null); + $this->setIfExists('offer_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_ids']) && (count($this->container['offer_ids']) > 500)) { + $invalidProperties[] = "invalid value for 'offer_ids', number of items must be less than or equal to 500."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets with_turnover + * + * @return bool|null + */ + public function getWithTurnover() + { + return $this->container['with_turnover']; + } + + /** + * Sets with_turnover + * + * @param bool|null $with_turnover **Только для модели FBY** Возвращать ли информацию по оборачиваемости. Значение по умолчанию — `false`. Если информация нужна, передайте значение `true`. + * + * @return self + */ + public function setWithTurnover($with_turnover) + { + if (is_null($with_turnover)) { + throw new \InvalidArgumentException('non-nullable with_turnover cannot be null'); + } + $this->container['with_turnover'] = $with_turnover; + + return $this; + } + + /** + * Gets archived + * + * @return bool|null + */ + public function getArchived() + { + return $this->container['archived']; + } + + /** + * Sets archived + * + * @param bool|null $archived Фильтр по нахождению в архиве. Передайте `true`, чтобы получить информацию об остатках товаров, которые находятся в архиве. Если фильтр не заполнен или передано `false`, в ответе возвращается информация о товарах, которые не находятся в архиве. + * + * @return self + */ + public function setArchived($archived) + { + if (is_null($archived)) { + throw new \InvalidArgumentException('non-nullable archived cannot be null'); + } + $this->container['archived'] = $archived; + + return $this; + } + + /** + * Gets offer_ids + * + * @return string[]|null + */ + public function getOfferIds() + { + return $this->container['offer_ids']; + } + + /** + * Sets offer_ids + * + * @param string[]|null $offer_ids Фильтр по вашим SKU товаров. Возвращается информация об остатках всех переданных SKU, включая товары в архиве. {% note warning \"Такой список возвращается только целиком\" %} Если вы запрашиваете информацию по конкретным SKU, не заполняйте: * `page_token` * `limit` * `archived` {% endnote %}   + * + * @return self + */ + public function setOfferIds($offer_ids) + { + if (is_null($offer_ids)) { + array_push($this->openAPINullablesSetToNull, 'offer_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('offer_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($offer_ids) && (count($offer_ids) > 500)) { + throw new \InvalidArgumentException('invalid value for $offer_ids when calling GetWarehouseStocksRequest., number of items must be less than or equal to 500.'); + } + $this->container['offer_ids'] = $offer_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetWarehouseStocksResponse.php b/erp24/lib/yandex_market_api/Model/GetWarehouseStocksResponse.php new file mode 100644 index 00000000..f6cac86d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetWarehouseStocksResponse.php @@ -0,0 +1,443 @@ + + */ +class GetWarehouseStocksResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetWarehouseStocksResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GetWarehouseStocksDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GetWarehouseStocksDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GetWarehouseStocksDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GetWarehousesResponse.php b/erp24/lib/yandex_market_api/Model/GetWarehousesResponse.php new file mode 100644 index 00000000..943b6528 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GetWarehousesResponse.php @@ -0,0 +1,443 @@ + + */ +class GetWarehousesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetWarehousesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\WarehousesDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\WarehousesDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\WarehousesDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentAuthorDTO.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentAuthorDTO.php new file mode 100644 index 00000000..e44d6cc9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentAuthorDTO.php @@ -0,0 +1,444 @@ + + */ +class GoodsFeedbackCommentAuthorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackCommentAuthorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\GoodsFeedbackCommentAuthorType', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\GoodsFeedbackCommentAuthorType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\GoodsFeedbackCommentAuthorType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Имя автора или название кабинета. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentAuthorType.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentAuthorType.php new file mode 100644 index 00000000..524f73bb --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentAuthorType.php @@ -0,0 +1,63 @@ + + */ +class GoodsFeedbackCommentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackCommentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'text' => 'string', + 'can_modify' => 'bool', + 'parent_id' => 'int', + 'author' => '\OpenAPI\Client\Model\GoodsFeedbackCommentAuthorDTO', + 'status' => '\OpenAPI\Client\Model\GoodsFeedbackCommentStatusType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'text' => null, + 'can_modify' => null, + 'parent_id' => 'int64', + 'author' => null, + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'text' => false, + 'can_modify' => false, + 'parent_id' => false, + 'author' => false, + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'text' => 'text', + 'can_modify' => 'canModify', + 'parent_id' => 'parentId', + 'author' => 'author', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'text' => 'setText', + 'can_modify' => 'setCanModify', + 'parent_id' => 'setParentId', + 'author' => 'setAuthor', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'text' => 'getText', + 'can_modify' => 'getCanModify', + 'parent_id' => 'getParentId', + 'author' => 'getAuthor', + 'status' => 'getStatus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('text', $data ?? [], null); + $this->setIfExists('can_modify', $data ?? [], null); + $this->setIfExists('parent_id', $data ?? [], null); + $this->setIfExists('author', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['text'] === null) { + $invalidProperties[] = "'text' can't be null"; + } + if ((mb_strlen($this->container['text']) > 4096)) { + $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 4096."; + } + + if ((mb_strlen($this->container['text']) < 1)) { + $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 1."; + } + + if ($this->container['author'] === null) { + $invalidProperties[] = "'author' can't be null"; + } + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор комментария к отзыву. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets text + * + * @return string + */ + public function getText() + { + return $this->container['text']; + } + + /** + * Sets text + * + * @param string $text Текст комментария. + * + * @return self + */ + public function setText($text) + { + if (is_null($text)) { + throw new \InvalidArgumentException('non-nullable text cannot be null'); + } + if ((mb_strlen($text) > 4096)) { + throw new \InvalidArgumentException('invalid length for $text when calling GoodsFeedbackCommentDTO., must be smaller than or equal to 4096.'); + } + if ((mb_strlen($text) < 1)) { + throw new \InvalidArgumentException('invalid length for $text when calling GoodsFeedbackCommentDTO., must be bigger than or equal to 1.'); + } + + $this->container['text'] = $text; + + return $this; + } + + /** + * Gets can_modify + * + * @return bool|null + */ + public function getCanModify() + { + return $this->container['can_modify']; + } + + /** + * Sets can_modify + * + * @param bool|null $can_modify Может ли продавец изменять комментарий или удалять его. + * + * @return self + */ + public function setCanModify($can_modify) + { + if (is_null($can_modify)) { + throw new \InvalidArgumentException('non-nullable can_modify cannot be null'); + } + $this->container['can_modify'] = $can_modify; + + return $this; + } + + /** + * Gets parent_id + * + * @return int|null + */ + public function getParentId() + { + return $this->container['parent_id']; + } + + /** + * Sets parent_id + * + * @param int|null $parent_id Идентификатор комментария к отзыву. + * + * @return self + */ + public function setParentId($parent_id) + { + if (is_null($parent_id)) { + throw new \InvalidArgumentException('non-nullable parent_id cannot be null'); + } + $this->container['parent_id'] = $parent_id; + + return $this; + } + + /** + * Gets author + * + * @return \OpenAPI\Client\Model\GoodsFeedbackCommentAuthorDTO + */ + public function getAuthor() + { + return $this->container['author']; + } + + /** + * Sets author + * + * @param \OpenAPI\Client\Model\GoodsFeedbackCommentAuthorDTO $author author + * + * @return self + */ + public function setAuthor($author) + { + if (is_null($author)) { + throw new \InvalidArgumentException('non-nullable author cannot be null'); + } + $this->container['author'] = $author; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\GoodsFeedbackCommentStatusType + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\GoodsFeedbackCommentStatusType $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentListDTO.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentListDTO.php new file mode 100644 index 00000000..df3ce6b4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentListDTO.php @@ -0,0 +1,447 @@ + + */ +class GoodsFeedbackCommentListDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackCommentListDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'comments' => '\OpenAPI\Client\Model\GoodsFeedbackCommentDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'comments' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'comments' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'comments' => 'comments', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'comments' => 'setComments', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'comments' => 'getComments', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('comments', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['comments'] === null) { + $invalidProperties[] = "'comments' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets comments + * + * @return \OpenAPI\Client\Model\GoodsFeedbackCommentDTO[] + */ + public function getComments() + { + return $this->container['comments']; + } + + /** + * Sets comments + * + * @param \OpenAPI\Client\Model\GoodsFeedbackCommentDTO[] $comments Список комментариев. + * + * @return self + */ + public function setComments($comments) + { + if (is_null($comments)) { + throw new \InvalidArgumentException('non-nullable comments cannot be null'); + } + $this->container['comments'] = $comments; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentStatusType.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentStatusType.php new file mode 100644 index 00000000..d6fb439b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackCommentStatusType.php @@ -0,0 +1,69 @@ + + */ +class GoodsFeedbackDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feedback_id' => 'int', + 'created_at' => '\DateTime', + 'need_reaction' => 'bool', + 'identifiers' => '\OpenAPI\Client\Model\GoodsFeedbackIdentifiersDTO', + 'author' => 'string', + 'description' => '\OpenAPI\Client\Model\GoodsFeedbackDescriptionDTO', + 'media' => '\OpenAPI\Client\Model\GoodsFeedbackMediaDTO', + 'statistics' => '\OpenAPI\Client\Model\GoodsFeedbackStatisticsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feedback_id' => 'int64', + 'created_at' => 'date-time', + 'need_reaction' => null, + 'identifiers' => null, + 'author' => null, + 'description' => null, + 'media' => null, + 'statistics' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feedback_id' => false, + 'created_at' => false, + 'need_reaction' => false, + 'identifiers' => false, + 'author' => false, + 'description' => false, + 'media' => false, + 'statistics' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'feedback_id' => 'feedbackId', + 'created_at' => 'createdAt', + 'need_reaction' => 'needReaction', + 'identifiers' => 'identifiers', + 'author' => 'author', + 'description' => 'description', + 'media' => 'media', + 'statistics' => 'statistics' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feedback_id' => 'setFeedbackId', + 'created_at' => 'setCreatedAt', + 'need_reaction' => 'setNeedReaction', + 'identifiers' => 'setIdentifiers', + 'author' => 'setAuthor', + 'description' => 'setDescription', + 'media' => 'setMedia', + 'statistics' => 'setStatistics' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feedback_id' => 'getFeedbackId', + 'created_at' => 'getCreatedAt', + 'need_reaction' => 'getNeedReaction', + 'identifiers' => 'getIdentifiers', + 'author' => 'getAuthor', + 'description' => 'getDescription', + 'media' => 'getMedia', + 'statistics' => 'getStatistics' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('feedback_id', $data ?? [], null); + $this->setIfExists('created_at', $data ?? [], null); + $this->setIfExists('need_reaction', $data ?? [], null); + $this->setIfExists('identifiers', $data ?? [], null); + $this->setIfExists('author', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('media', $data ?? [], null); + $this->setIfExists('statistics', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['feedback_id'] === null) { + $invalidProperties[] = "'feedback_id' can't be null"; + } + if ($this->container['created_at'] === null) { + $invalidProperties[] = "'created_at' can't be null"; + } + if ($this->container['need_reaction'] === null) { + $invalidProperties[] = "'need_reaction' can't be null"; + } + if ($this->container['identifiers'] === null) { + $invalidProperties[] = "'identifiers' can't be null"; + } + if ($this->container['statistics'] === null) { + $invalidProperties[] = "'statistics' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets feedback_id + * + * @return int + */ + public function getFeedbackId() + { + return $this->container['feedback_id']; + } + + /** + * Sets feedback_id + * + * @param int $feedback_id Идентификатор отзыва. + * + * @return self + */ + public function setFeedbackId($feedback_id) + { + if (is_null($feedback_id)) { + throw new \InvalidArgumentException('non-nullable feedback_id cannot be null'); + } + $this->container['feedback_id'] = $feedback_id; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime $created_at Дата и время создания отзыва. + * + * @return self + */ + public function setCreatedAt($created_at) + { + if (is_null($created_at)) { + throw new \InvalidArgumentException('non-nullable created_at cannot be null'); + } + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets need_reaction + * + * @return bool + */ + public function getNeedReaction() + { + return $this->container['need_reaction']; + } + + /** + * Sets need_reaction + * + * @param bool $need_reaction Нужен ли ответ на отзыв. + * + * @return self + */ + public function setNeedReaction($need_reaction) + { + if (is_null($need_reaction)) { + throw new \InvalidArgumentException('non-nullable need_reaction cannot be null'); + } + $this->container['need_reaction'] = $need_reaction; + + return $this; + } + + /** + * Gets identifiers + * + * @return \OpenAPI\Client\Model\GoodsFeedbackIdentifiersDTO + */ + public function getIdentifiers() + { + return $this->container['identifiers']; + } + + /** + * Sets identifiers + * + * @param \OpenAPI\Client\Model\GoodsFeedbackIdentifiersDTO $identifiers identifiers + * + * @return self + */ + public function setIdentifiers($identifiers) + { + if (is_null($identifiers)) { + throw new \InvalidArgumentException('non-nullable identifiers cannot be null'); + } + $this->container['identifiers'] = $identifiers; + + return $this; + } + + /** + * Gets author + * + * @return string|null + */ + public function getAuthor() + { + return $this->container['author']; + } + + /** + * Sets author + * + * @param string|null $author Имя автора отзыва. + * + * @return self + */ + public function setAuthor($author) + { + if (is_null($author)) { + throw new \InvalidArgumentException('non-nullable author cannot be null'); + } + $this->container['author'] = $author; + + return $this; + } + + /** + * Gets description + * + * @return \OpenAPI\Client\Model\GoodsFeedbackDescriptionDTO|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param \OpenAPI\Client\Model\GoodsFeedbackDescriptionDTO|null $description description + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets media + * + * @return \OpenAPI\Client\Model\GoodsFeedbackMediaDTO|null + */ + public function getMedia() + { + return $this->container['media']; + } + + /** + * Sets media + * + * @param \OpenAPI\Client\Model\GoodsFeedbackMediaDTO|null $media media + * + * @return self + */ + public function setMedia($media) + { + if (is_null($media)) { + throw new \InvalidArgumentException('non-nullable media cannot be null'); + } + $this->container['media'] = $media; + + return $this; + } + + /** + * Gets statistics + * + * @return \OpenAPI\Client\Model\GoodsFeedbackStatisticsDTO + */ + public function getStatistics() + { + return $this->container['statistics']; + } + + /** + * Sets statistics + * + * @param \OpenAPI\Client\Model\GoodsFeedbackStatisticsDTO $statistics statistics + * + * @return self + */ + public function setStatistics($statistics) + { + if (is_null($statistics)) { + throw new \InvalidArgumentException('non-nullable statistics cannot be null'); + } + $this->container['statistics'] = $statistics; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackDescriptionDTO.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackDescriptionDTO.php new file mode 100644 index 00000000..062cad84 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackDescriptionDTO.php @@ -0,0 +1,478 @@ + + */ +class GoodsFeedbackDescriptionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackDescriptionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'advantages' => 'string', + 'disadvantages' => 'string', + 'comment' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'advantages' => null, + 'disadvantages' => null, + 'comment' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'advantages' => false, + 'disadvantages' => false, + 'comment' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'advantages' => 'advantages', + 'disadvantages' => 'disadvantages', + 'comment' => 'comment' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'advantages' => 'setAdvantages', + 'disadvantages' => 'setDisadvantages', + 'comment' => 'setComment' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'advantages' => 'getAdvantages', + 'disadvantages' => 'getDisadvantages', + 'comment' => 'getComment' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('advantages', $data ?? [], null); + $this->setIfExists('disadvantages', $data ?? [], null); + $this->setIfExists('comment', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets advantages + * + * @return string|null + */ + public function getAdvantages() + { + return $this->container['advantages']; + } + + /** + * Sets advantages + * + * @param string|null $advantages Описание плюсов товара в отзыве. + * + * @return self + */ + public function setAdvantages($advantages) + { + if (is_null($advantages)) { + throw new \InvalidArgumentException('non-nullable advantages cannot be null'); + } + $this->container['advantages'] = $advantages; + + return $this; + } + + /** + * Gets disadvantages + * + * @return string|null + */ + public function getDisadvantages() + { + return $this->container['disadvantages']; + } + + /** + * Sets disadvantages + * + * @param string|null $disadvantages Описание минусов товара в отзыве. + * + * @return self + */ + public function setDisadvantages($disadvantages) + { + if (is_null($disadvantages)) { + throw new \InvalidArgumentException('non-nullable disadvantages cannot be null'); + } + $this->container['disadvantages'] = $disadvantages; + + return $this; + } + + /** + * Gets comment + * + * @return string|null + */ + public function getComment() + { + return $this->container['comment']; + } + + /** + * Sets comment + * + * @param string|null $comment Комментарий в отзыве. + * + * @return self + */ + public function setComment($comment) + { + if (is_null($comment)) { + throw new \InvalidArgumentException('non-nullable comment cannot be null'); + } + $this->container['comment'] = $comment; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackIdentifiersDTO.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackIdentifiersDTO.php new file mode 100644 index 00000000..e95748a0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackIdentifiersDTO.php @@ -0,0 +1,450 @@ + + */ +class GoodsFeedbackIdentifiersDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackIdentifiersDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order_id' => 'int', + 'model_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order_id' => 'int64', + 'model_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order_id' => false, + 'model_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order_id' => 'orderId', + 'model_id' => 'modelId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order_id' => 'setOrderId', + 'model_id' => 'setModelId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order_id' => 'getOrderId', + 'model_id' => 'getModelId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order_id', $data ?? [], null); + $this->setIfExists('model_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['order_id'] === null) { + $invalidProperties[] = "'order_id' can't be null"; + } + if ($this->container['model_id'] === null) { + $invalidProperties[] = "'model_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order_id + * + * @return int + */ + public function getOrderId() + { + return $this->container['order_id']; + } + + /** + * Sets order_id + * + * @param int $order_id Идентификатор заказа на Маркете. + * + * @return self + */ + public function setOrderId($order_id) + { + if (is_null($order_id)) { + throw new \InvalidArgumentException('non-nullable order_id cannot be null'); + } + $this->container['order_id'] = $order_id; + + return $this; + } + + /** + * Gets model_id + * + * @return int + */ + public function getModelId() + { + return $this->container['model_id']; + } + + /** + * Sets model_id + * + * @param int $model_id Идентификатор модели товара. + * + * @return self + */ + public function setModelId($model_id) + { + if (is_null($model_id)) { + throw new \InvalidArgumentException('non-nullable model_id cannot be null'); + } + $this->container['model_id'] = $model_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackListDTO.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackListDTO.php new file mode 100644 index 00000000..dad1e5ac --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackListDTO.php @@ -0,0 +1,447 @@ + + */ +class GoodsFeedbackListDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackListDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feedbacks' => '\OpenAPI\Client\Model\GoodsFeedbackDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feedbacks' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feedbacks' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'feedbacks' => 'feedbacks', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feedbacks' => 'setFeedbacks', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feedbacks' => 'getFeedbacks', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('feedbacks', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['feedbacks'] === null) { + $invalidProperties[] = "'feedbacks' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets feedbacks + * + * @return \OpenAPI\Client\Model\GoodsFeedbackDTO[] + */ + public function getFeedbacks() + { + return $this->container['feedbacks']; + } + + /** + * Sets feedbacks + * + * @param \OpenAPI\Client\Model\GoodsFeedbackDTO[] $feedbacks Список отзывов. + * + * @return self + */ + public function setFeedbacks($feedbacks) + { + if (is_null($feedbacks)) { + throw new \InvalidArgumentException('non-nullable feedbacks cannot be null'); + } + $this->container['feedbacks'] = $feedbacks; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackMediaDTO.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackMediaDTO.php new file mode 100644 index 00000000..25214a22 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackMediaDTO.php @@ -0,0 +1,458 @@ + + */ +class GoodsFeedbackMediaDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackMediaDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'photos' => 'string[]', + 'videos' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'photos' => null, + 'videos' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'photos' => true, + 'videos' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'photos' => 'photos', + 'videos' => 'videos' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'photos' => 'setPhotos', + 'videos' => 'setVideos' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'photos' => 'getPhotos', + 'videos' => 'getVideos' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('photos', $data ?? [], null); + $this->setIfExists('videos', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets photos + * + * @return string[]|null + */ + public function getPhotos() + { + return $this->container['photos']; + } + + /** + * Sets photos + * + * @param string[]|null $photos Ссылки на фото. + * + * @return self + */ + public function setPhotos($photos) + { + if (is_null($photos)) { + array_push($this->openAPINullablesSetToNull, 'photos'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('photos', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['photos'] = $photos; + + return $this; + } + + /** + * Gets videos + * + * @return string[]|null + */ + public function getVideos() + { + return $this->container['videos']; + } + + /** + * Sets videos + * + * @param string[]|null $videos Ссылки на видео. + * + * @return self + */ + public function setVideos($videos) + { + if (is_null($videos)) { + array_push($this->openAPINullablesSetToNull, 'videos'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('videos', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['videos'] = $videos; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsFeedbackStatisticsDTO.php b/erp24/lib/yandex_market_api/Model/GoodsFeedbackStatisticsDTO.php new file mode 100644 index 00000000..5bd387e9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsFeedbackStatisticsDTO.php @@ -0,0 +1,534 @@ + + */ +class GoodsFeedbackStatisticsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsFeedbackStatisticsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rating' => 'int', + 'comments_count' => 'int', + 'recommended' => 'bool', + 'paid_amount' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rating' => 'int32', + 'comments_count' => 'int64', + 'recommended' => null, + 'paid_amount' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rating' => false, + 'comments_count' => false, + 'recommended' => false, + 'paid_amount' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rating' => 'rating', + 'comments_count' => 'commentsCount', + 'recommended' => 'recommended', + 'paid_amount' => 'paidAmount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rating' => 'setRating', + 'comments_count' => 'setCommentsCount', + 'recommended' => 'setRecommended', + 'paid_amount' => 'setPaidAmount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rating' => 'getRating', + 'comments_count' => 'getCommentsCount', + 'recommended' => 'getRecommended', + 'paid_amount' => 'getPaidAmount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('rating', $data ?? [], null); + $this->setIfExists('comments_count', $data ?? [], null); + $this->setIfExists('recommended', $data ?? [], null); + $this->setIfExists('paid_amount', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['rating'] === null) { + $invalidProperties[] = "'rating' can't be null"; + } + if (($this->container['rating'] > 5)) { + $invalidProperties[] = "invalid value for 'rating', must be smaller than or equal to 5."; + } + + if (($this->container['rating'] < 1)) { + $invalidProperties[] = "invalid value for 'rating', must be bigger than or equal to 1."; + } + + if ($this->container['comments_count'] === null) { + $invalidProperties[] = "'comments_count' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets rating + * + * @return int + */ + public function getRating() + { + return $this->container['rating']; + } + + /** + * Sets rating + * + * @param int $rating Оценка товара. + * + * @return self + */ + public function setRating($rating) + { + if (is_null($rating)) { + throw new \InvalidArgumentException('non-nullable rating cannot be null'); + } + + if (($rating > 5)) { + throw new \InvalidArgumentException('invalid value for $rating when calling GoodsFeedbackStatisticsDTO., must be smaller than or equal to 5.'); + } + if (($rating < 1)) { + throw new \InvalidArgumentException('invalid value for $rating when calling GoodsFeedbackStatisticsDTO., must be bigger than or equal to 1.'); + } + + $this->container['rating'] = $rating; + + return $this; + } + + /** + * Gets comments_count + * + * @return int + */ + public function getCommentsCount() + { + return $this->container['comments_count']; + } + + /** + * Sets comments_count + * + * @param int $comments_count Количество комментариев к отзыву. Учитываются только ответы на отзывы, а не дочерние комментарии. + * + * @return self + */ + public function setCommentsCount($comments_count) + { + if (is_null($comments_count)) { + throw new \InvalidArgumentException('non-nullable comments_count cannot be null'); + } + $this->container['comments_count'] = $comments_count; + + return $this; + } + + /** + * Gets recommended + * + * @return bool|null + */ + public function getRecommended() + { + return $this->container['recommended']; + } + + /** + * Sets recommended + * + * @param bool|null $recommended Рекомендуют ли этот товар. + * + * @return self + */ + public function setRecommended($recommended) + { + if (is_null($recommended)) { + throw new \InvalidArgumentException('non-nullable recommended cannot be null'); + } + $this->container['recommended'] = $recommended; + + return $this; + } + + /** + * Gets paid_amount + * + * @return int|null + */ + public function getPaidAmount() + { + return $this->container['paid_amount']; + } + + /** + * Sets paid_amount + * + * @param int|null $paid_amount Количество баллов Плюса, которое автор получил за отзыв. + * + * @return self + */ + public function setPaidAmount($paid_amount) + { + if (is_null($paid_amount)) { + throw new \InvalidArgumentException('non-nullable paid_amount cannot be null'); + } + $this->container['paid_amount'] = $paid_amount; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsStatsDTO.php b/erp24/lib/yandex_market_api/Model/GoodsStatsDTO.php new file mode 100644 index 00000000..312a35f1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsStatsDTO.php @@ -0,0 +1,413 @@ + + */ +class GoodsStatsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsStatsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'shop_skus' => '\OpenAPI\Client\Model\GoodsStatsGoodsDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'shop_skus' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'shop_skus' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'shop_skus' => 'shopSkus' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'shop_skus' => 'setShopSkus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'shop_skus' => 'getShopSkus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('shop_skus', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['shop_skus'] === null) { + $invalidProperties[] = "'shop_skus' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets shop_skus + * + * @return \OpenAPI\Client\Model\GoodsStatsGoodsDTO[] + */ + public function getShopSkus() + { + return $this->container['shop_skus']; + } + + /** + * Sets shop_skus + * + * @param \OpenAPI\Client\Model\GoodsStatsGoodsDTO[] $shop_skus Список товаров. + * + * @return self + */ + public function setShopSkus($shop_skus) + { + if (is_null($shop_skus)) { + throw new \InvalidArgumentException('non-nullable shop_skus cannot be null'); + } + $this->container['shop_skus'] = $shop_skus; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsStatsGoodsDTO.php b/erp24/lib/yandex_market_api/Model/GoodsStatsGoodsDTO.php new file mode 100644 index 00000000..ea20e336 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsStatsGoodsDTO.php @@ -0,0 +1,768 @@ + + */ +class GoodsStatsGoodsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsStatsGoodsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'shop_sku' => 'string', + 'market_sku' => 'int', + 'name' => 'string', + 'price' => 'float', + 'category_id' => 'int', + 'category_name' => 'string', + 'weight_dimensions' => '\OpenAPI\Client\Model\GoodsStatsWeightDimensionsDTO', + 'warehouses' => '\OpenAPI\Client\Model\GoodsStatsWarehouseDTO[]', + 'tariffs' => '\OpenAPI\Client\Model\TariffDTO[]', + 'pictures' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'shop_sku' => null, + 'market_sku' => 'int64', + 'name' => null, + 'price' => null, + 'category_id' => 'int64', + 'category_name' => null, + 'weight_dimensions' => null, + 'warehouses' => null, + 'tariffs' => null, + 'pictures' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'shop_sku' => false, + 'market_sku' => false, + 'name' => false, + 'price' => false, + 'category_id' => false, + 'category_name' => false, + 'weight_dimensions' => false, + 'warehouses' => true, + 'tariffs' => true, + 'pictures' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'shop_sku' => 'shopSku', + 'market_sku' => 'marketSku', + 'name' => 'name', + 'price' => 'price', + 'category_id' => 'categoryId', + 'category_name' => 'categoryName', + 'weight_dimensions' => 'weightDimensions', + 'warehouses' => 'warehouses', + 'tariffs' => 'tariffs', + 'pictures' => 'pictures' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'shop_sku' => 'setShopSku', + 'market_sku' => 'setMarketSku', + 'name' => 'setName', + 'price' => 'setPrice', + 'category_id' => 'setCategoryId', + 'category_name' => 'setCategoryName', + 'weight_dimensions' => 'setWeightDimensions', + 'warehouses' => 'setWarehouses', + 'tariffs' => 'setTariffs', + 'pictures' => 'setPictures' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'shop_sku' => 'getShopSku', + 'market_sku' => 'getMarketSku', + 'name' => 'getName', + 'price' => 'getPrice', + 'category_id' => 'getCategoryId', + 'category_name' => 'getCategoryName', + 'weight_dimensions' => 'getWeightDimensions', + 'warehouses' => 'getWarehouses', + 'tariffs' => 'getTariffs', + 'pictures' => 'getPictures' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('shop_sku', $data ?? [], null); + $this->setIfExists('market_sku', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('category_id', $data ?? [], null); + $this->setIfExists('category_name', $data ?? [], null); + $this->setIfExists('weight_dimensions', $data ?? [], null); + $this->setIfExists('warehouses', $data ?? [], null); + $this->setIfExists('tariffs', $data ?? [], null); + $this->setIfExists('pictures', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets shop_sku + * + * @return string|null + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string|null $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling GoodsStatsGoodsDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling GoodsStatsGoodsDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling GoodsStatsGoodsDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling GoodsStatsGoodsDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название товара. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price Цена на товар в валюте, которая установлена [в кабинете продавца на Маркете](https://partner.market.yandex.ru/). + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets category_id + * + * @return int|null + */ + public function getCategoryId() + { + return $this->container['category_id']; + } + + /** + * Sets category_id + * + * @param int|null $category_id Идентификатор категории товара на Маркете. + * + * @return self + */ + public function setCategoryId($category_id) + { + if (is_null($category_id)) { + throw new \InvalidArgumentException('non-nullable category_id cannot be null'); + } + $this->container['category_id'] = $category_id; + + return $this; + } + + /** + * Gets category_name + * + * @return string|null + */ + public function getCategoryName() + { + return $this->container['category_name']; + } + + /** + * Sets category_name + * + * @param string|null $category_name Название категории товара на Маркете. + * + * @return self + */ + public function setCategoryName($category_name) + { + if (is_null($category_name)) { + throw new \InvalidArgumentException('non-nullable category_name cannot be null'); + } + $this->container['category_name'] = $category_name; + + return $this; + } + + /** + * Gets weight_dimensions + * + * @return \OpenAPI\Client\Model\GoodsStatsWeightDimensionsDTO|null + */ + public function getWeightDimensions() + { + return $this->container['weight_dimensions']; + } + + /** + * Sets weight_dimensions + * + * @param \OpenAPI\Client\Model\GoodsStatsWeightDimensionsDTO|null $weight_dimensions weight_dimensions + * + * @return self + */ + public function setWeightDimensions($weight_dimensions) + { + if (is_null($weight_dimensions)) { + throw new \InvalidArgumentException('non-nullable weight_dimensions cannot be null'); + } + $this->container['weight_dimensions'] = $weight_dimensions; + + return $this; + } + + /** + * Gets warehouses + * + * @return \OpenAPI\Client\Model\GoodsStatsWarehouseDTO[]|null + */ + public function getWarehouses() + { + return $this->container['warehouses']; + } + + /** + * Sets warehouses + * + * @param \OpenAPI\Client\Model\GoodsStatsWarehouseDTO[]|null $warehouses Информация о складах, на которых хранится товар. Параметр не приходит, если товара нет ни на одном складе. + * + * @return self + */ + public function setWarehouses($warehouses) + { + if (is_null($warehouses)) { + array_push($this->openAPINullablesSetToNull, 'warehouses'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('warehouses', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['warehouses'] = $warehouses; + + return $this; + } + + /** + * Gets tariffs + * + * @return \OpenAPI\Client\Model\TariffDTO[]|null + */ + public function getTariffs() + { + return $this->container['tariffs']; + } + + /** + * Sets tariffs + * + * @param \OpenAPI\Client\Model\TariffDTO[]|null $tariffs Информация о тарифах, по которым нужно заплатить за услуги Маркета. По некоторым услугам могут возвращаться несколько разных стоимостей. Например, в модели FBS стоимость услуги `SORTING` (обработка заказа) зависит от способа отгрузки и количества заказов в отгрузке. Подробнее о тарифах на услуги читайте [в Справке Маркета для продавцов](https://yandex.ru/support2/marketplace/ru/introduction/rates/models/). + * + * @return self + */ + public function setTariffs($tariffs) + { + if (is_null($tariffs)) { + array_push($this->openAPINullablesSetToNull, 'tariffs'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tariffs', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tariffs'] = $tariffs; + + return $this; + } + + /** + * Gets pictures + * + * @return string[]|null + */ + public function getPictures() + { + return $this->container['pictures']; + } + + /** + * Sets pictures + * + * @param string[]|null $pictures Ссылки (URL) изображений товара в хорошем качестве. + * + * @return self + */ + public function setPictures($pictures) + { + if (is_null($pictures)) { + array_push($this->openAPINullablesSetToNull, 'pictures'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('pictures', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['pictures'] = $pictures; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsStatsWarehouseDTO.php b/erp24/lib/yandex_market_api/Model/GoodsStatsWarehouseDTO.php new file mode 100644 index 00000000..4b951045 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsStatsWarehouseDTO.php @@ -0,0 +1,481 @@ + + */ +class GoodsStatsWarehouseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsStatsWarehouseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'stocks' => '\OpenAPI\Client\Model\WarehouseStockDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'stocks' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'stocks' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'stocks' => 'stocks' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'stocks' => 'setStocks' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'stocks' => 'getStocks' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('stocks', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['stocks'] === null) { + $invalidProperties[] = "'stocks' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор склада. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название склада. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets stocks + * + * @return \OpenAPI\Client\Model\WarehouseStockDTO[] + */ + public function getStocks() + { + return $this->container['stocks']; + } + + /** + * Sets stocks + * + * @param \OpenAPI\Client\Model\WarehouseStockDTO[] $stocks Информация об остатках товаров на складе. + * + * @return self + */ + public function setStocks($stocks) + { + if (is_null($stocks)) { + throw new \InvalidArgumentException('non-nullable stocks cannot be null'); + } + $this->container['stocks'] = $stocks; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GoodsStatsWeightDimensionsDTO.php b/erp24/lib/yandex_market_api/Model/GoodsStatsWeightDimensionsDTO.php new file mode 100644 index 00000000..d3b124f1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GoodsStatsWeightDimensionsDTO.php @@ -0,0 +1,512 @@ + + */ +class GoodsStatsWeightDimensionsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GoodsStatsWeightDimensionsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'length' => 'float', + 'width' => 'float', + 'height' => 'float', + 'weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'length' => null, + 'width' => null, + 'height' => null, + 'weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'length' => false, + 'width' => false, + 'height' => false, + 'weight' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'length' => 'length', + 'width' => 'width', + 'height' => 'height', + 'weight' => 'weight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'length' => 'setLength', + 'width' => 'setWidth', + 'height' => 'setHeight', + 'weight' => 'setWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'length' => 'getLength', + 'width' => 'getWidth', + 'height' => 'getHeight', + 'weight' => 'getWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('length', $data ?? [], null); + $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('height', $data ?? [], null); + $this->setIfExists('weight', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets length + * + * @return float|null + */ + public function getLength() + { + return $this->container['length']; + } + + /** + * Sets length + * + * @param float|null $length Длина товара в сантиметрах. + * + * @return self + */ + public function setLength($length) + { + if (is_null($length)) { + throw new \InvalidArgumentException('non-nullable length cannot be null'); + } + $this->container['length'] = $length; + + return $this; + } + + /** + * Gets width + * + * @return float|null + */ + public function getWidth() + { + return $this->container['width']; + } + + /** + * Sets width + * + * @param float|null $width Ширина товара в сантиметрах. + * + * @return self + */ + public function setWidth($width) + { + if (is_null($width)) { + throw new \InvalidArgumentException('non-nullable width cannot be null'); + } + $this->container['width'] = $width; + + return $this; + } + + /** + * Gets height + * + * @return float|null + */ + public function getHeight() + { + return $this->container['height']; + } + + /** + * Sets height + * + * @param float|null $height Высота товара в сантиметрах. + * + * @return self + */ + public function setHeight($height) + { + if (is_null($height)) { + throw new \InvalidArgumentException('non-nullable height cannot be null'); + } + $this->container['height'] = $height; + + return $this; + } + + /** + * Gets weight + * + * @return float|null + */ + public function getWeight() + { + return $this->container['weight']; + } + + /** + * Sets weight + * + * @param float|null $weight Вес товара в килограммах. + * + * @return self + */ + public function setWeight($weight) + { + if (is_null($weight)) { + throw new \InvalidArgumentException('non-nullable weight cannot be null'); + } + $this->container['weight'] = $weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/GpsDTO.php b/erp24/lib/yandex_market_api/Model/GpsDTO.php new file mode 100644 index 00000000..99f11f25 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/GpsDTO.php @@ -0,0 +1,450 @@ + + */ +class GpsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GpsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'latitude' => 'float', + 'longitude' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'latitude' => 'decimal', + 'longitude' => 'decimal' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'latitude' => false, + 'longitude' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'latitude' => 'latitude', + 'longitude' => 'longitude' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'latitude' => 'setLatitude', + 'longitude' => 'setLongitude' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'latitude' => 'getLatitude', + 'longitude' => 'getLongitude' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('latitude', $data ?? [], null); + $this->setIfExists('longitude', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['latitude'] === null) { + $invalidProperties[] = "'latitude' can't be null"; + } + if ($this->container['longitude'] === null) { + $invalidProperties[] = "'longitude' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets latitude + * + * @return float + */ + public function getLatitude() + { + return $this->container['latitude']; + } + + /** + * Sets latitude + * + * @param float $latitude Широта. + * + * @return self + */ + public function setLatitude($latitude) + { + if (is_null($latitude)) { + throw new \InvalidArgumentException('non-nullable latitude cannot be null'); + } + $this->container['latitude'] = $latitude; + + return $this; + } + + /** + * Gets longitude + * + * @return float + */ + public function getLongitude() + { + return $this->container['longitude']; + } + + /** + * Sets longitude + * + * @param float $longitude Долгота. + * + * @return self + */ + public function setLongitude($longitude) + { + if (is_null($longitude)) { + throw new \InvalidArgumentException('non-nullable longitude cannot be null'); + } + $this->container['longitude'] = $longitude; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/HiddenOfferDTO.php b/erp24/lib/yandex_market_api/Model/HiddenOfferDTO.php new file mode 100644 index 00000000..23e1feb0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/HiddenOfferDTO.php @@ -0,0 +1,435 @@ + + */ +class HiddenOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'HiddenOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling HiddenOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling HiddenOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling HiddenOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/LabelsSortingType.php b/erp24/lib/yandex_market_api/Model/LabelsSortingType.php new file mode 100644 index 00000000..e9237b7f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/LabelsSortingType.php @@ -0,0 +1,63 @@ + + */ +class LogisticPickupPointDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'LogisticPickupPointDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'address' => '\OpenAPI\Client\Model\PickupAddressDTO', + 'instruction' => 'string', + 'type' => '\OpenAPI\Client\Model\LogisticPointType', + 'logistic_partner_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'address' => null, + 'instruction' => null, + 'type' => null, + 'logistic_partner_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'address' => false, + 'instruction' => false, + 'type' => false, + 'logistic_partner_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'address' => 'address', + 'instruction' => 'instruction', + 'type' => 'type', + 'logistic_partner_id' => 'logisticPartnerId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'address' => 'setAddress', + 'instruction' => 'setInstruction', + 'type' => 'setType', + 'logistic_partner_id' => 'setLogisticPartnerId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'address' => 'getAddress', + 'instruction' => 'getInstruction', + 'type' => 'getType', + 'logistic_partner_id' => 'getLogisticPartnerId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('address', $data ?? [], null); + $this->setIfExists('instruction', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('logistic_partner_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор пункта вывоза. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название пункта вывоза. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets address + * + * @return \OpenAPI\Client\Model\PickupAddressDTO|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \OpenAPI\Client\Model\PickupAddressDTO|null $address address + * + * @return self + */ + public function setAddress($address) + { + if (is_null($address)) { + throw new \InvalidArgumentException('non-nullable address cannot be null'); + } + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets instruction + * + * @return string|null + */ + public function getInstruction() + { + return $this->container['instruction']; + } + + /** + * Sets instruction + * + * @param string|null $instruction Дополнительные инструкции к вывозу. + * + * @return self + */ + public function setInstruction($instruction) + { + if (is_null($instruction)) { + throw new \InvalidArgumentException('non-nullable instruction cannot be null'); + } + $this->container['instruction'] = $instruction; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\LogisticPointType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\LogisticPointType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets logistic_partner_id + * + * @return int|null + */ + public function getLogisticPartnerId() + { + return $this->container['logistic_partner_id']; + } + + /** + * Sets logistic_partner_id + * + * @param int|null $logistic_partner_id Идентификатор логистического партнера, к которому относится логистическая точка. + * + * @return self + */ + public function setLogisticPartnerId($logistic_partner_id) + { + if (is_null($logistic_partner_id)) { + throw new \InvalidArgumentException('non-nullable logistic_partner_id cannot be null'); + } + $this->container['logistic_partner_id'] = $logistic_partner_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/LogisticPointType.php b/erp24/lib/yandex_market_api/Model/LogisticPointType.php new file mode 100644 index 00000000..8052f372 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/LogisticPointType.php @@ -0,0 +1,78 @@ + + */ +class MappingsOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'MappingsOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'shop_sku' => 'string', + 'category' => 'string', + 'vendor' => 'string', + 'vendor_code' => 'string', + 'description' => 'string', + 'id' => 'string', + 'feed_id' => 'int', + 'barcodes' => 'string[]', + 'urls' => 'string[]', + 'pictures' => 'string[]', + 'manufacturer' => 'string', + 'manufacturer_countries' => 'string[]', + 'min_shipment' => 'int', + 'transport_unit_size' => 'int', + 'quantum_of_supply' => 'int', + 'delivery_duration_days' => 'int', + 'box_count' => 'int', + 'customs_commodity_codes' => 'string[]', + 'weight_dimensions' => '\OpenAPI\Client\Model\OfferWeightDimensionsDTO', + 'supply_schedule_days' => '\OpenAPI\Client\Model\DayOfWeekType[]', + 'shelf_life_days' => 'int', + 'life_time_days' => 'int', + 'guarantee_period_days' => 'int', + 'processing_state' => '\OpenAPI\Client\Model\OfferProcessingStateDTO', + 'availability' => '\OpenAPI\Client\Model\OfferAvailabilityStatusType', + 'shelf_life' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'life_time' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'guarantee_period' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'certificate' => 'string', + 'price' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'shop_sku' => null, + 'category' => null, + 'vendor' => null, + 'vendor_code' => null, + 'description' => null, + 'id' => null, + 'feed_id' => 'int64', + 'barcodes' => null, + 'urls' => null, + 'pictures' => null, + 'manufacturer' => null, + 'manufacturer_countries' => null, + 'min_shipment' => 'int32', + 'transport_unit_size' => 'int32', + 'quantum_of_supply' => 'int32', + 'delivery_duration_days' => 'int32', + 'box_count' => 'int32', + 'customs_commodity_codes' => null, + 'weight_dimensions' => null, + 'supply_schedule_days' => null, + 'shelf_life_days' => 'int32', + 'life_time_days' => 'int32', + 'guarantee_period_days' => 'int32', + 'processing_state' => null, + 'availability' => null, + 'shelf_life' => null, + 'life_time' => null, + 'guarantee_period' => null, + 'certificate' => null, + 'price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'shop_sku' => false, + 'category' => false, + 'vendor' => false, + 'vendor_code' => false, + 'description' => false, + 'id' => false, + 'feed_id' => false, + 'barcodes' => true, + 'urls' => true, + 'pictures' => true, + 'manufacturer' => false, + 'manufacturer_countries' => true, + 'min_shipment' => false, + 'transport_unit_size' => false, + 'quantum_of_supply' => false, + 'delivery_duration_days' => false, + 'box_count' => false, + 'customs_commodity_codes' => true, + 'weight_dimensions' => false, + 'supply_schedule_days' => true, + 'shelf_life_days' => false, + 'life_time_days' => false, + 'guarantee_period_days' => false, + 'processing_state' => false, + 'availability' => false, + 'shelf_life' => false, + 'life_time' => false, + 'guarantee_period' => false, + 'certificate' => false, + 'price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'shop_sku' => 'shopSku', + 'category' => 'category', + 'vendor' => 'vendor', + 'vendor_code' => 'vendorCode', + 'description' => 'description', + 'id' => 'id', + 'feed_id' => 'feedId', + 'barcodes' => 'barcodes', + 'urls' => 'urls', + 'pictures' => 'pictures', + 'manufacturer' => 'manufacturer', + 'manufacturer_countries' => 'manufacturerCountries', + 'min_shipment' => 'minShipment', + 'transport_unit_size' => 'transportUnitSize', + 'quantum_of_supply' => 'quantumOfSupply', + 'delivery_duration_days' => 'deliveryDurationDays', + 'box_count' => 'boxCount', + 'customs_commodity_codes' => 'customsCommodityCodes', + 'weight_dimensions' => 'weightDimensions', + 'supply_schedule_days' => 'supplyScheduleDays', + 'shelf_life_days' => 'shelfLifeDays', + 'life_time_days' => 'lifeTimeDays', + 'guarantee_period_days' => 'guaranteePeriodDays', + 'processing_state' => 'processingState', + 'availability' => 'availability', + 'shelf_life' => 'shelfLife', + 'life_time' => 'lifeTime', + 'guarantee_period' => 'guaranteePeriod', + 'certificate' => 'certificate', + 'price' => 'price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'shop_sku' => 'setShopSku', + 'category' => 'setCategory', + 'vendor' => 'setVendor', + 'vendor_code' => 'setVendorCode', + 'description' => 'setDescription', + 'id' => 'setId', + 'feed_id' => 'setFeedId', + 'barcodes' => 'setBarcodes', + 'urls' => 'setUrls', + 'pictures' => 'setPictures', + 'manufacturer' => 'setManufacturer', + 'manufacturer_countries' => 'setManufacturerCountries', + 'min_shipment' => 'setMinShipment', + 'transport_unit_size' => 'setTransportUnitSize', + 'quantum_of_supply' => 'setQuantumOfSupply', + 'delivery_duration_days' => 'setDeliveryDurationDays', + 'box_count' => 'setBoxCount', + 'customs_commodity_codes' => 'setCustomsCommodityCodes', + 'weight_dimensions' => 'setWeightDimensions', + 'supply_schedule_days' => 'setSupplyScheduleDays', + 'shelf_life_days' => 'setShelfLifeDays', + 'life_time_days' => 'setLifeTimeDays', + 'guarantee_period_days' => 'setGuaranteePeriodDays', + 'processing_state' => 'setProcessingState', + 'availability' => 'setAvailability', + 'shelf_life' => 'setShelfLife', + 'life_time' => 'setLifeTime', + 'guarantee_period' => 'setGuaranteePeriod', + 'certificate' => 'setCertificate', + 'price' => 'setPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'shop_sku' => 'getShopSku', + 'category' => 'getCategory', + 'vendor' => 'getVendor', + 'vendor_code' => 'getVendorCode', + 'description' => 'getDescription', + 'id' => 'getId', + 'feed_id' => 'getFeedId', + 'barcodes' => 'getBarcodes', + 'urls' => 'getUrls', + 'pictures' => 'getPictures', + 'manufacturer' => 'getManufacturer', + 'manufacturer_countries' => 'getManufacturerCountries', + 'min_shipment' => 'getMinShipment', + 'transport_unit_size' => 'getTransportUnitSize', + 'quantum_of_supply' => 'getQuantumOfSupply', + 'delivery_duration_days' => 'getDeliveryDurationDays', + 'box_count' => 'getBoxCount', + 'customs_commodity_codes' => 'getCustomsCommodityCodes', + 'weight_dimensions' => 'getWeightDimensions', + 'supply_schedule_days' => 'getSupplyScheduleDays', + 'shelf_life_days' => 'getShelfLifeDays', + 'life_time_days' => 'getLifeTimeDays', + 'guarantee_period_days' => 'getGuaranteePeriodDays', + 'processing_state' => 'getProcessingState', + 'availability' => 'getAvailability', + 'shelf_life' => 'getShelfLife', + 'life_time' => 'getLifeTime', + 'guarantee_period' => 'getGuaranteePeriod', + 'certificate' => 'getCertificate', + 'price' => 'getPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('shop_sku', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); + $this->setIfExists('vendor', $data ?? [], null); + $this->setIfExists('vendor_code', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('feed_id', $data ?? [], null); + $this->setIfExists('barcodes', $data ?? [], null); + $this->setIfExists('urls', $data ?? [], null); + $this->setIfExists('pictures', $data ?? [], null); + $this->setIfExists('manufacturer', $data ?? [], null); + $this->setIfExists('manufacturer_countries', $data ?? [], null); + $this->setIfExists('min_shipment', $data ?? [], null); + $this->setIfExists('transport_unit_size', $data ?? [], null); + $this->setIfExists('quantum_of_supply', $data ?? [], null); + $this->setIfExists('delivery_duration_days', $data ?? [], null); + $this->setIfExists('box_count', $data ?? [], null); + $this->setIfExists('customs_commodity_codes', $data ?? [], null); + $this->setIfExists('weight_dimensions', $data ?? [], null); + $this->setIfExists('supply_schedule_days', $data ?? [], null); + $this->setIfExists('shelf_life_days', $data ?? [], null); + $this->setIfExists('life_time_days', $data ?? [], null); + $this->setIfExists('guarantee_period_days', $data ?? [], null); + $this->setIfExists('processing_state', $data ?? [], null); + $this->setIfExists('availability', $data ?? [], null); + $this->setIfExists('shelf_life', $data ?? [], null); + $this->setIfExists('life_time', $data ?? [], null); + $this->setIfExists('guarantee_period', $data ?? [], null); + $this->setIfExists('certificate', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 256)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 6000)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 6000."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 255)) { + $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) < 1)) { + $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['id'])) { + $invalidProperties[] = "invalid value for 'id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Составляйте название по схеме: тип + бренд или производитель + модель + особенности, если есть (например, цвет, размер или вес) и количество в упаковке. Не включайте в название условия продажи (например, «скидка», «бесплатная доставка» и т. д.), эмоциональные характеристики («хит», «супер» и т. д.). Не пишите слова большими буквами — кроме устоявшихся названий брендов и моделей. Оптимальная длина — 50–60 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/title.html) + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + if ((mb_strlen($name) > 256)) { + throw new \InvalidArgumentException('invalid length for $name when calling MappingsOfferDTO., must be smaller than or equal to 256.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets shop_sku + * + * @return string|null + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string|null $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling MappingsOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling MappingsOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling MappingsOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category Категория товара в вашем магазине. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. Указывайте конкретные категории — например, набор ножей лучше отнести к категории **Столовые приборы**, а не просто **Посуда**. Выбирайте категории, которые описывают товар, а не абстрактный признак — например, **Духи**, а не **Подарки**. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. + * + * @return self + */ + public function setCategory($category) + { + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets vendor + * + * @return string|null + */ + public function getVendor() + { + return $this->container['vendor']; + } + + /** + * Sets vendor + * + * @param string|null $vendor Название бренда или производителя. Должно быть записано так, как его пишет сам бренд. + * + * @return self + */ + public function setVendor($vendor) + { + if (is_null($vendor)) { + throw new \InvalidArgumentException('non-nullable vendor cannot be null'); + } + $this->container['vendor'] = $vendor; + + return $this; + } + + /** + * Gets vendor_code + * + * @return string|null + */ + public function getVendorCode() + { + return $this->container['vendor_code']; + } + + /** + * Sets vendor_code + * + * @param string|null $vendor_code Артикул товара от производителя. + * + * @return self + */ + public function setVendorCode($vendor_code) + { + if (is_null($vendor_code)) { + throw new \InvalidArgumentException('non-nullable vendor_code cannot be null'); + } + $this->container['vendor_code'] = $vendor_code; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Подробное описание товара: например, его преимущества и особенности. Не давайте в описании инструкций по установке и сборке. Не используйте слова «скидка», «распродажа», «дешевый», «подарок» (кроме подарочных категорий), «бесплатно», «акция», «специальная цена», «новинка», «new», «аналог», «заказ», «хит». Не указывайте никакой контактной информации и не давайте ссылок. Можно использовать теги: * \\, \\

                          , \\

                          и так далее — для заголовков; * \\
                          и \\

                          — для переноса строки; * \\

                            — для нумерованного списка; * \\
                              — для маркированного списка; * \\
                            • — для создания элементов списка (должен находиться внутри \\
                                или \\
                                  ); * \\
                                  — поддерживается, но не влияет на отображение текста. Оптимальная длина — 400–600 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/description.html) + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + if ((mb_strlen($description) > 6000)) { + throw new \InvalidArgumentException('invalid length for $description when calling MappingsOfferDTO., must be smaller than or equal to 6000.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + if ((mb_strlen($id) > 255)) { + throw new \InvalidArgumentException('invalid length for $id when calling MappingsOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($id) < 1)) { + throw new \InvalidArgumentException('invalid length for $id when calling MappingsOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($id)))) { + throw new \InvalidArgumentException("invalid value for \$id when calling MappingsOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets feed_id + * + * @return int|null + */ + public function getFeedId() + { + return $this->container['feed_id']; + } + + /** + * Sets feed_id + * + * @param int|null $feed_id Идентификатор фида. + * + * @return self + */ + public function setFeedId($feed_id) + { + if (is_null($feed_id)) { + throw new \InvalidArgumentException('non-nullable feed_id cannot be null'); + } + $this->container['feed_id'] = $feed_id; + + return $this; + } + + /** + * Gets barcodes + * + * @return string[]|null + */ + public function getBarcodes() + { + return $this->container['barcodes']; + } + + /** + * Sets barcodes + * + * @param string[]|null $barcodes Указывайте в виде последовательности цифр. Подойдут коды EAN-13, EAN-8, UPC-A, UPC-E или Code 128. Для книг указывайте ISBN. Для товаров [определенных категорий и торговых марок](https://yastatic.net/s3/doc-binary/src/support/market/ru/yandex-market-list-for-gtin.xlsx) штрихкод должен быть действительным кодом GTIN. Обратите внимание: внутренние штрихкоды, начинающиеся на 2 или 02, и коды формата Code 128 не являются GTIN. [Что такое GTIN](*gtin) + * + * @return self + */ + public function setBarcodes($barcodes) + { + if (is_null($barcodes)) { + array_push($this->openAPINullablesSetToNull, 'barcodes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('barcodes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['barcodes'] = $barcodes; + + return $this; + } + + /** + * Gets urls + * + * @return string[]|null + */ + public function getUrls() + { + return $this->container['urls']; + } + + /** + * Sets urls + * + * @param string[]|null $urls URL фотографии товара или страницы с описанием на вашем сайте. Переданные данные не будут отображаться на витрине, но они помогут специалистам Маркета найти карточку для вашего товара. Должен содержать один вложенный параметр url. + * + * @return self + */ + public function setUrls($urls) + { + if (is_null($urls)) { + array_push($this->openAPINullablesSetToNull, 'urls'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('urls', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['urls'] = $urls; + + return $this; + } + + /** + * Gets pictures + * + * @return string[]|null + */ + public function getPictures() + { + return $this->container['pictures']; + } + + /** + * Sets pictures + * + * @param string[]|null $pictures Ссылки (URL) изображений товара в хорошем качестве. Можно указать до 30 ссылок. При этом изображение по первой ссылке будет основным. Оно используется в качестве изображения товара в поиске Маркета и на карточке товара. Другие изображения товара доступны в режиме просмотра увеличенных изображений. Обязательный параметр. Должен содержать хотя бы один вложенный параметр `picture`. + * + * @return self + */ + public function setPictures($pictures) + { + if (is_null($pictures)) { + array_push($this->openAPINullablesSetToNull, 'pictures'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('pictures', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['pictures'] = $pictures; + + return $this; + } + + /** + * Gets manufacturer + * + * @return string|null + */ + public function getManufacturer() + { + return $this->container['manufacturer']; + } + + /** + * Sets manufacturer + * + * @param string|null $manufacturer Изготовитель товара: компания, которая произвела товар, ее адрес и регистрационный номер (если есть). Необязательный параметр. + * + * @return self + */ + public function setManufacturer($manufacturer) + { + if (is_null($manufacturer)) { + throw new \InvalidArgumentException('non-nullable manufacturer cannot be null'); + } + $this->container['manufacturer'] = $manufacturer; + + return $this; + } + + /** + * Gets manufacturer_countries + * + * @return string[]|null + */ + public function getManufacturerCountries() + { + return $this->container['manufacturer_countries']; + } + + /** + * Sets manufacturer_countries + * + * @param string[]|null $manufacturer_countries Список стран, в которых произведен товар. Обязательный параметр. Должен содержать хотя бы одну, но не больше 5 стран. + * + * @return self + */ + public function setManufacturerCountries($manufacturer_countries) + { + if (is_null($manufacturer_countries)) { + array_push($this->openAPINullablesSetToNull, 'manufacturer_countries'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manufacturer_countries', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['manufacturer_countries'] = $manufacturer_countries; + + return $this; + } + + /** + * Gets min_shipment + * + * @return int|null + */ + public function getMinShipment() + { + return $this->container['min_shipment']; + } + + /** + * Sets min_shipment + * + * @param int|null $min_shipment Минимальное количество единиц товара, которое вы поставляете на склад. Например, если вы поставляете детское питание партиями минимум по 10 коробок, а в каждой коробке по 6 баночек, укажите значение 60. + * + * @return self + */ + public function setMinShipment($min_shipment) + { + if (is_null($min_shipment)) { + throw new \InvalidArgumentException('non-nullable min_shipment cannot be null'); + } + $this->container['min_shipment'] = $min_shipment; + + return $this; + } + + /** + * Gets transport_unit_size + * + * @return int|null + */ + public function getTransportUnitSize() + { + return $this->container['transport_unit_size']; + } + + /** + * Sets transport_unit_size + * + * @param int|null $transport_unit_size Количество единиц товара в одной упаковке, которую вы поставляете на склад. Например, если вы поставляете детское питание коробками по 6 баночек, укажите значение 6. + * + * @return self + */ + public function setTransportUnitSize($transport_unit_size) + { + if (is_null($transport_unit_size)) { + throw new \InvalidArgumentException('non-nullable transport_unit_size cannot be null'); + } + $this->container['transport_unit_size'] = $transport_unit_size; + + return $this; + } + + /** + * Gets quantum_of_supply + * + * @return int|null + */ + public function getQuantumOfSupply() + { + return $this->container['quantum_of_supply']; + } + + /** + * Sets quantum_of_supply + * + * @param int|null $quantum_of_supply Добавочная партия: по сколько единиц товара можно добавлять к минимальному количеству minShipment. Например, если вы поставляете детское питание партиями минимум по 10 коробок и хотите добавлять к минимальной партии по 2 коробки, а в каждой коробке по 6 баночек, укажите значение 12. + * + * @return self + */ + public function setQuantumOfSupply($quantum_of_supply) + { + if (is_null($quantum_of_supply)) { + throw new \InvalidArgumentException('non-nullable quantum_of_supply cannot be null'); + } + $this->container['quantum_of_supply'] = $quantum_of_supply; + + return $this; + } + + /** + * Gets delivery_duration_days + * + * @return int|null + */ + public function getDeliveryDurationDays() + { + return $this->container['delivery_duration_days']; + } + + /** + * Sets delivery_duration_days + * + * @param int|null $delivery_duration_days Срок, за который продавец поставляет товары на склад, в днях. + * + * @return self + */ + public function setDeliveryDurationDays($delivery_duration_days) + { + if (is_null($delivery_duration_days)) { + throw new \InvalidArgumentException('non-nullable delivery_duration_days cannot be null'); + } + $this->container['delivery_duration_days'] = $delivery_duration_days; + + return $this; + } + + /** + * Gets box_count + * + * @return int|null + */ + public function getBoxCount() + { + return $this->container['box_count']; + } + + /** + * Sets box_count + * + * @param int|null $box_count Сколько мест (если больше одного) занимает товар. Параметр указывается, только если товар занимает больше одного места (например, кондиционер занимает два места: внешний и внутренний блоки в двух коробках). Если товар занимает одно место, не указывайте этот параметр. + * + * @return self + */ + public function setBoxCount($box_count) + { + if (is_null($box_count)) { + throw new \InvalidArgumentException('non-nullable box_count cannot be null'); + } + $this->container['box_count'] = $box_count; + + return $this; + } + + /** + * Gets customs_commodity_codes + * + * @return string[]|null + */ + public function getCustomsCommodityCodes() + { + return $this->container['customs_commodity_codes']; + } + + /** + * Sets customs_commodity_codes + * + * @param string[]|null $customs_commodity_codes Список кодов товара в единой Товарной номенклатуре внешнеэкономической деятельности (ТН ВЭД). Обязательный параметр, если товар подлежит особому учету (например, в системе «Меркурий» как продукция животного происхождения или в системе «Честный ЗНАК»). Может содержать только один вложенный код ТН ВЭД. + * + * @return self + */ + public function setCustomsCommodityCodes($customs_commodity_codes) + { + if (is_null($customs_commodity_codes)) { + array_push($this->openAPINullablesSetToNull, 'customs_commodity_codes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('customs_commodity_codes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['customs_commodity_codes'] = $customs_commodity_codes; + + return $this; + } + + /** + * Gets weight_dimensions + * + * @return \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null + */ + public function getWeightDimensions() + { + return $this->container['weight_dimensions']; + } + + /** + * Sets weight_dimensions + * + * @param \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null $weight_dimensions weight_dimensions + * + * @return self + */ + public function setWeightDimensions($weight_dimensions) + { + if (is_null($weight_dimensions)) { + throw new \InvalidArgumentException('non-nullable weight_dimensions cannot be null'); + } + $this->container['weight_dimensions'] = $weight_dimensions; + + return $this; + } + + /** + * Gets supply_schedule_days + * + * @return \OpenAPI\Client\Model\DayOfWeekType[]|null + */ + public function getSupplyScheduleDays() + { + return $this->container['supply_schedule_days']; + } + + /** + * Sets supply_schedule_days + * + * @param \OpenAPI\Client\Model\DayOfWeekType[]|null $supply_schedule_days Дни недели, в которые продавец поставляет товары на склад. + * + * @return self + */ + public function setSupplyScheduleDays($supply_schedule_days) + { + if (is_null($supply_schedule_days)) { + array_push($this->openAPINullablesSetToNull, 'supply_schedule_days'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('supply_schedule_days', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['supply_schedule_days'] = $supply_schedule_days; + + return $this; + } + + /** + * Gets shelf_life_days + * + * @return int|null + */ + public function getShelfLifeDays() + { + return $this->container['shelf_life_days']; + } + + /** + * Sets shelf_life_days + * + * @param int|null $shelf_life_days {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `shelfLife`. Совместное использование обоих параметров приведет к ошибке. {% endnote %} Срок годности: через сколько дней товар станет непригоден для использования. + * + * @return self + */ + public function setShelfLifeDays($shelf_life_days) + { + if (is_null($shelf_life_days)) { + throw new \InvalidArgumentException('non-nullable shelf_life_days cannot be null'); + } + $this->container['shelf_life_days'] = $shelf_life_days; + + return $this; + } + + /** + * Gets life_time_days + * + * @return int|null + */ + public function getLifeTimeDays() + { + return $this->container['life_time_days']; + } + + /** + * Sets life_time_days + * + * @param int|null $life_time_days {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `lifeTime`. Совместное использование обоих параметров приведет к ошибке. {% endnote %} Срок службы: сколько дней товар будет исправно выполнять свою функцию, а изготовитель — нести ответственность за его существенные недостатки. + * + * @return self + */ + public function setLifeTimeDays($life_time_days) + { + if (is_null($life_time_days)) { + throw new \InvalidArgumentException('non-nullable life_time_days cannot be null'); + } + $this->container['life_time_days'] = $life_time_days; + + return $this; + } + + /** + * Gets guarantee_period_days + * + * @return int|null + */ + public function getGuaranteePeriodDays() + { + return $this->container['guarantee_period_days']; + } + + /** + * Sets guarantee_period_days + * + * @param int|null $guarantee_period_days Гарантийный срок товара: сколько дней возможно обслуживание и ремонт товара или возврат денег, а изготовитель или продавец будет нести ответственность за недостатки товара. + * + * @return self + */ + public function setGuaranteePeriodDays($guarantee_period_days) + { + if (is_null($guarantee_period_days)) { + throw new \InvalidArgumentException('non-nullable guarantee_period_days cannot be null'); + } + $this->container['guarantee_period_days'] = $guarantee_period_days; + + return $this; + } + + /** + * Gets processing_state + * + * @return \OpenAPI\Client\Model\OfferProcessingStateDTO|null + */ + public function getProcessingState() + { + return $this->container['processing_state']; + } + + /** + * Sets processing_state + * + * @param \OpenAPI\Client\Model\OfferProcessingStateDTO|null $processing_state processing_state + * + * @return self + */ + public function setProcessingState($processing_state) + { + if (is_null($processing_state)) { + throw new \InvalidArgumentException('non-nullable processing_state cannot be null'); + } + $this->container['processing_state'] = $processing_state; + + return $this; + } + + /** + * Gets availability + * + * @return \OpenAPI\Client\Model\OfferAvailabilityStatusType|null + */ + public function getAvailability() + { + return $this->container['availability']; + } + + /** + * Sets availability + * + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType|null $availability availability + * + * @return self + */ + public function setAvailability($availability) + { + if (is_null($availability)) { + throw new \InvalidArgumentException('non-nullable availability cannot be null'); + } + $this->container['availability'] = $availability; + + return $this; + } + + /** + * Gets shelf_life + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getShelfLife() + { + return $this->container['shelf_life']; + } + + /** + * Sets shelf_life + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $shelf_life shelf_life + * + * @return self + */ + public function setShelfLife($shelf_life) + { + if (is_null($shelf_life)) { + throw new \InvalidArgumentException('non-nullable shelf_life cannot be null'); + } + $this->container['shelf_life'] = $shelf_life; + + return $this; + } + + /** + * Gets life_time + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getLifeTime() + { + return $this->container['life_time']; + } + + /** + * Sets life_time + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $life_time life_time + * + * @return self + */ + public function setLifeTime($life_time) + { + if (is_null($life_time)) { + throw new \InvalidArgumentException('non-nullable life_time cannot be null'); + } + $this->container['life_time'] = $life_time; + + return $this; + } + + /** + * Gets guarantee_period + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getGuaranteePeriod() + { + return $this->container['guarantee_period']; + } + + /** + * Sets guarantee_period + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $guarantee_period guarantee_period + * + * @return self + */ + public function setGuaranteePeriod($guarantee_period) + { + if (is_null($guarantee_period)) { + throw new \InvalidArgumentException('non-nullable guarantee_period cannot be null'); + } + $this->container['guarantee_period'] = $guarantee_period; + + return $this; + } + + /** + * Gets certificate + * + * @return string|null + */ + public function getCertificate() + { + return $this->container['certificate']; + } + + /** + * Sets certificate + * + * @param string|null $certificate Номер документа на товар. Перед указанием номера документ нужно загрузить в кабинете продавца на Маркете. [Инструкция](https://yandex.ru/support/marketplace/assortment/restrictions/certificates.html) + * + * @return self + */ + public function setCertificate($certificate) + { + if (is_null($certificate)) { + throw new \InvalidArgumentException('non-nullable certificate cannot be null'); + } + $this->container['certificate'] = $certificate; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price Цена на товар в рублях. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/MappingsOfferInfoDTO.php b/erp24/lib/yandex_market_api/Model/MappingsOfferInfoDTO.php new file mode 100644 index 00000000..e17e71c8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/MappingsOfferInfoDTO.php @@ -0,0 +1,1498 @@ + + */ +class MappingsOfferInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'MappingsOfferInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'shop_sku' => 'string', + 'category' => 'string', + 'vendor' => 'string', + 'vendor_code' => 'string', + 'description' => 'string', + 'id' => 'string', + 'feed_id' => 'int', + 'barcodes' => 'string[]', + 'urls' => 'string[]', + 'pictures' => 'string[]', + 'manufacturer' => 'string', + 'manufacturer_countries' => 'string[]', + 'min_shipment' => 'int', + 'transport_unit_size' => 'int', + 'quantum_of_supply' => 'int', + 'delivery_duration_days' => 'int', + 'box_count' => 'int', + 'customs_commodity_codes' => 'string[]', + 'weight_dimensions' => '\OpenAPI\Client\Model\OfferWeightDimensionsDTO', + 'supply_schedule_days' => '\OpenAPI\Client\Model\DayOfWeekType[]', + 'shelf_life_days' => 'int', + 'life_time_days' => 'int', + 'guarantee_period_days' => 'int', + 'processing_state' => '\OpenAPI\Client\Model\OfferProcessingStateDTO', + 'availability' => '\OpenAPI\Client\Model\OfferAvailabilityStatusType', + 'shelf_life' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'life_time' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'guarantee_period' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'certificate' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'shop_sku' => null, + 'category' => null, + 'vendor' => null, + 'vendor_code' => null, + 'description' => null, + 'id' => null, + 'feed_id' => 'int64', + 'barcodes' => null, + 'urls' => null, + 'pictures' => null, + 'manufacturer' => null, + 'manufacturer_countries' => null, + 'min_shipment' => 'int32', + 'transport_unit_size' => 'int32', + 'quantum_of_supply' => 'int32', + 'delivery_duration_days' => 'int32', + 'box_count' => 'int32', + 'customs_commodity_codes' => null, + 'weight_dimensions' => null, + 'supply_schedule_days' => null, + 'shelf_life_days' => 'int32', + 'life_time_days' => 'int32', + 'guarantee_period_days' => 'int32', + 'processing_state' => null, + 'availability' => null, + 'shelf_life' => null, + 'life_time' => null, + 'guarantee_period' => null, + 'certificate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'shop_sku' => false, + 'category' => false, + 'vendor' => false, + 'vendor_code' => false, + 'description' => false, + 'id' => false, + 'feed_id' => false, + 'barcodes' => true, + 'urls' => true, + 'pictures' => true, + 'manufacturer' => false, + 'manufacturer_countries' => true, + 'min_shipment' => false, + 'transport_unit_size' => false, + 'quantum_of_supply' => false, + 'delivery_duration_days' => false, + 'box_count' => false, + 'customs_commodity_codes' => true, + 'weight_dimensions' => false, + 'supply_schedule_days' => true, + 'shelf_life_days' => false, + 'life_time_days' => false, + 'guarantee_period_days' => false, + 'processing_state' => false, + 'availability' => false, + 'shelf_life' => false, + 'life_time' => false, + 'guarantee_period' => false, + 'certificate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'shop_sku' => 'shopSku', + 'category' => 'category', + 'vendor' => 'vendor', + 'vendor_code' => 'vendorCode', + 'description' => 'description', + 'id' => 'id', + 'feed_id' => 'feedId', + 'barcodes' => 'barcodes', + 'urls' => 'urls', + 'pictures' => 'pictures', + 'manufacturer' => 'manufacturer', + 'manufacturer_countries' => 'manufacturerCountries', + 'min_shipment' => 'minShipment', + 'transport_unit_size' => 'transportUnitSize', + 'quantum_of_supply' => 'quantumOfSupply', + 'delivery_duration_days' => 'deliveryDurationDays', + 'box_count' => 'boxCount', + 'customs_commodity_codes' => 'customsCommodityCodes', + 'weight_dimensions' => 'weightDimensions', + 'supply_schedule_days' => 'supplyScheduleDays', + 'shelf_life_days' => 'shelfLifeDays', + 'life_time_days' => 'lifeTimeDays', + 'guarantee_period_days' => 'guaranteePeriodDays', + 'processing_state' => 'processingState', + 'availability' => 'availability', + 'shelf_life' => 'shelfLife', + 'life_time' => 'lifeTime', + 'guarantee_period' => 'guaranteePeriod', + 'certificate' => 'certificate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'shop_sku' => 'setShopSku', + 'category' => 'setCategory', + 'vendor' => 'setVendor', + 'vendor_code' => 'setVendorCode', + 'description' => 'setDescription', + 'id' => 'setId', + 'feed_id' => 'setFeedId', + 'barcodes' => 'setBarcodes', + 'urls' => 'setUrls', + 'pictures' => 'setPictures', + 'manufacturer' => 'setManufacturer', + 'manufacturer_countries' => 'setManufacturerCountries', + 'min_shipment' => 'setMinShipment', + 'transport_unit_size' => 'setTransportUnitSize', + 'quantum_of_supply' => 'setQuantumOfSupply', + 'delivery_duration_days' => 'setDeliveryDurationDays', + 'box_count' => 'setBoxCount', + 'customs_commodity_codes' => 'setCustomsCommodityCodes', + 'weight_dimensions' => 'setWeightDimensions', + 'supply_schedule_days' => 'setSupplyScheduleDays', + 'shelf_life_days' => 'setShelfLifeDays', + 'life_time_days' => 'setLifeTimeDays', + 'guarantee_period_days' => 'setGuaranteePeriodDays', + 'processing_state' => 'setProcessingState', + 'availability' => 'setAvailability', + 'shelf_life' => 'setShelfLife', + 'life_time' => 'setLifeTime', + 'guarantee_period' => 'setGuaranteePeriod', + 'certificate' => 'setCertificate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'shop_sku' => 'getShopSku', + 'category' => 'getCategory', + 'vendor' => 'getVendor', + 'vendor_code' => 'getVendorCode', + 'description' => 'getDescription', + 'id' => 'getId', + 'feed_id' => 'getFeedId', + 'barcodes' => 'getBarcodes', + 'urls' => 'getUrls', + 'pictures' => 'getPictures', + 'manufacturer' => 'getManufacturer', + 'manufacturer_countries' => 'getManufacturerCountries', + 'min_shipment' => 'getMinShipment', + 'transport_unit_size' => 'getTransportUnitSize', + 'quantum_of_supply' => 'getQuantumOfSupply', + 'delivery_duration_days' => 'getDeliveryDurationDays', + 'box_count' => 'getBoxCount', + 'customs_commodity_codes' => 'getCustomsCommodityCodes', + 'weight_dimensions' => 'getWeightDimensions', + 'supply_schedule_days' => 'getSupplyScheduleDays', + 'shelf_life_days' => 'getShelfLifeDays', + 'life_time_days' => 'getLifeTimeDays', + 'guarantee_period_days' => 'getGuaranteePeriodDays', + 'processing_state' => 'getProcessingState', + 'availability' => 'getAvailability', + 'shelf_life' => 'getShelfLife', + 'life_time' => 'getLifeTime', + 'guarantee_period' => 'getGuaranteePeriod', + 'certificate' => 'getCertificate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('shop_sku', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); + $this->setIfExists('vendor', $data ?? [], null); + $this->setIfExists('vendor_code', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('feed_id', $data ?? [], null); + $this->setIfExists('barcodes', $data ?? [], null); + $this->setIfExists('urls', $data ?? [], null); + $this->setIfExists('pictures', $data ?? [], null); + $this->setIfExists('manufacturer', $data ?? [], null); + $this->setIfExists('manufacturer_countries', $data ?? [], null); + $this->setIfExists('min_shipment', $data ?? [], null); + $this->setIfExists('transport_unit_size', $data ?? [], null); + $this->setIfExists('quantum_of_supply', $data ?? [], null); + $this->setIfExists('delivery_duration_days', $data ?? [], null); + $this->setIfExists('box_count', $data ?? [], null); + $this->setIfExists('customs_commodity_codes', $data ?? [], null); + $this->setIfExists('weight_dimensions', $data ?? [], null); + $this->setIfExists('supply_schedule_days', $data ?? [], null); + $this->setIfExists('shelf_life_days', $data ?? [], null); + $this->setIfExists('life_time_days', $data ?? [], null); + $this->setIfExists('guarantee_period_days', $data ?? [], null); + $this->setIfExists('processing_state', $data ?? [], null); + $this->setIfExists('availability', $data ?? [], null); + $this->setIfExists('shelf_life', $data ?? [], null); + $this->setIfExists('life_time', $data ?? [], null); + $this->setIfExists('guarantee_period', $data ?? [], null); + $this->setIfExists('certificate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 256)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 6000)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 6000."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 255)) { + $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) < 1)) { + $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['id'])) { + $invalidProperties[] = "invalid value for 'id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Составляйте название по схеме: тип + бренд или производитель + модель + особенности, если есть (например, цвет, размер или вес) и количество в упаковке. Не включайте в название условия продажи (например, «скидка», «бесплатная доставка» и т. д.), эмоциональные характеристики («хит», «супер» и т. д.). Не пишите слова большими буквами — кроме устоявшихся названий брендов и моделей. Оптимальная длина — 50–60 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/title.html) + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + if ((mb_strlen($name) > 256)) { + throw new \InvalidArgumentException('invalid length for $name when calling MappingsOfferInfoDTO., must be smaller than or equal to 256.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets shop_sku + * + * @return string|null + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string|null $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling MappingsOfferInfoDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling MappingsOfferInfoDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling MappingsOfferInfoDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category Категория товара в вашем магазине. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. Указывайте конкретные категории — например, набор ножей лучше отнести к категории **Столовые приборы**, а не просто **Посуда**. Выбирайте категории, которые описывают товар, а не абстрактный признак — например, **Духи**, а не **Подарки**. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. + * + * @return self + */ + public function setCategory($category) + { + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets vendor + * + * @return string|null + */ + public function getVendor() + { + return $this->container['vendor']; + } + + /** + * Sets vendor + * + * @param string|null $vendor Название бренда или производителя. Должно быть записано так, как его пишет сам бренд. + * + * @return self + */ + public function setVendor($vendor) + { + if (is_null($vendor)) { + throw new \InvalidArgumentException('non-nullable vendor cannot be null'); + } + $this->container['vendor'] = $vendor; + + return $this; + } + + /** + * Gets vendor_code + * + * @return string|null + */ + public function getVendorCode() + { + return $this->container['vendor_code']; + } + + /** + * Sets vendor_code + * + * @param string|null $vendor_code Артикул товара от производителя. + * + * @return self + */ + public function setVendorCode($vendor_code) + { + if (is_null($vendor_code)) { + throw new \InvalidArgumentException('non-nullable vendor_code cannot be null'); + } + $this->container['vendor_code'] = $vendor_code; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Подробное описание товара: например, его преимущества и особенности. Не давайте в описании инструкций по установке и сборке. Не используйте слова «скидка», «распродажа», «дешевый», «подарок» (кроме подарочных категорий), «бесплатно», «акция», «специальная цена», «новинка», «new», «аналог», «заказ», «хит». Не указывайте никакой контактной информации и не давайте ссылок. Можно использовать теги: * \\, \\

                                  , \\

                                  и так далее — для заголовков; * \\
                                  и \\

                                  — для переноса строки; * \\

                                    — для нумерованного списка; * \\
                                      — для маркированного списка; * \\
                                    • — для создания элементов списка (должен находиться внутри \\
                                        или \\
                                          ); * \\
                                          — поддерживается, но не влияет на отображение текста. Оптимальная длина — 400–600 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/description.html) + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + if ((mb_strlen($description) > 6000)) { + throw new \InvalidArgumentException('invalid length for $description when calling MappingsOfferInfoDTO., must be smaller than or equal to 6000.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + if ((mb_strlen($id) > 255)) { + throw new \InvalidArgumentException('invalid length for $id when calling MappingsOfferInfoDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($id) < 1)) { + throw new \InvalidArgumentException('invalid length for $id when calling MappingsOfferInfoDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($id)))) { + throw new \InvalidArgumentException("invalid value for \$id when calling MappingsOfferInfoDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets feed_id + * + * @return int|null + */ + public function getFeedId() + { + return $this->container['feed_id']; + } + + /** + * Sets feed_id + * + * @param int|null $feed_id Идентификатор фида. + * + * @return self + */ + public function setFeedId($feed_id) + { + if (is_null($feed_id)) { + throw new \InvalidArgumentException('non-nullable feed_id cannot be null'); + } + $this->container['feed_id'] = $feed_id; + + return $this; + } + + /** + * Gets barcodes + * + * @return string[]|null + */ + public function getBarcodes() + { + return $this->container['barcodes']; + } + + /** + * Sets barcodes + * + * @param string[]|null $barcodes Указывайте в виде последовательности цифр. Подойдут коды EAN-13, EAN-8, UPC-A, UPC-E или Code 128. Для книг указывайте ISBN. Для товаров [определенных категорий и торговых марок](https://yastatic.net/s3/doc-binary/src/support/market/ru/yandex-market-list-for-gtin.xlsx) штрихкод должен быть действительным кодом GTIN. Обратите внимание: внутренние штрихкоды, начинающиеся на 2 или 02, и коды формата Code 128 не являются GTIN. [Что такое GTIN](*gtin) + * + * @return self + */ + public function setBarcodes($barcodes) + { + if (is_null($barcodes)) { + array_push($this->openAPINullablesSetToNull, 'barcodes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('barcodes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['barcodes'] = $barcodes; + + return $this; + } + + /** + * Gets urls + * + * @return string[]|null + */ + public function getUrls() + { + return $this->container['urls']; + } + + /** + * Sets urls + * + * @param string[]|null $urls URL фотографии товара или страницы с описанием на вашем сайте. Переданные данные не будут отображаться на витрине, но они помогут специалистам Маркета найти карточку для вашего товара. Должен содержать один вложенный параметр url. + * + * @return self + */ + public function setUrls($urls) + { + if (is_null($urls)) { + array_push($this->openAPINullablesSetToNull, 'urls'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('urls', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['urls'] = $urls; + + return $this; + } + + /** + * Gets pictures + * + * @return string[]|null + */ + public function getPictures() + { + return $this->container['pictures']; + } + + /** + * Sets pictures + * + * @param string[]|null $pictures Ссылки (URL) изображений товара в хорошем качестве. Можно указать до 30 ссылок. При этом изображение по первой ссылке будет основным. Оно используется в качестве изображения товара в поиске Маркета и на карточке товара. Другие изображения товара доступны в режиме просмотра увеличенных изображений. Обязательный параметр. Должен содержать хотя бы один вложенный параметр `picture`. + * + * @return self + */ + public function setPictures($pictures) + { + if (is_null($pictures)) { + array_push($this->openAPINullablesSetToNull, 'pictures'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('pictures', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['pictures'] = $pictures; + + return $this; + } + + /** + * Gets manufacturer + * + * @return string|null + */ + public function getManufacturer() + { + return $this->container['manufacturer']; + } + + /** + * Sets manufacturer + * + * @param string|null $manufacturer Изготовитель товара: компания, которая произвела товар, ее адрес и регистрационный номер (если есть). Необязательный параметр. + * + * @return self + */ + public function setManufacturer($manufacturer) + { + if (is_null($manufacturer)) { + throw new \InvalidArgumentException('non-nullable manufacturer cannot be null'); + } + $this->container['manufacturer'] = $manufacturer; + + return $this; + } + + /** + * Gets manufacturer_countries + * + * @return string[]|null + */ + public function getManufacturerCountries() + { + return $this->container['manufacturer_countries']; + } + + /** + * Sets manufacturer_countries + * + * @param string[]|null $manufacturer_countries Список стран, в которых произведен товар. Обязательный параметр. Должен содержать хотя бы одну, но не больше 5 стран. + * + * @return self + */ + public function setManufacturerCountries($manufacturer_countries) + { + if (is_null($manufacturer_countries)) { + array_push($this->openAPINullablesSetToNull, 'manufacturer_countries'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manufacturer_countries', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['manufacturer_countries'] = $manufacturer_countries; + + return $this; + } + + /** + * Gets min_shipment + * + * @return int|null + */ + public function getMinShipment() + { + return $this->container['min_shipment']; + } + + /** + * Sets min_shipment + * + * @param int|null $min_shipment Минимальное количество единиц товара, которое вы поставляете на склад. Например, если вы поставляете детское питание партиями минимум по 10 коробок, а в каждой коробке по 6 баночек, укажите значение 60. + * + * @return self + */ + public function setMinShipment($min_shipment) + { + if (is_null($min_shipment)) { + throw new \InvalidArgumentException('non-nullable min_shipment cannot be null'); + } + $this->container['min_shipment'] = $min_shipment; + + return $this; + } + + /** + * Gets transport_unit_size + * + * @return int|null + */ + public function getTransportUnitSize() + { + return $this->container['transport_unit_size']; + } + + /** + * Sets transport_unit_size + * + * @param int|null $transport_unit_size Количество единиц товара в одной упаковке, которую вы поставляете на склад. Например, если вы поставляете детское питание коробками по 6 баночек, укажите значение 6. + * + * @return self + */ + public function setTransportUnitSize($transport_unit_size) + { + if (is_null($transport_unit_size)) { + throw new \InvalidArgumentException('non-nullable transport_unit_size cannot be null'); + } + $this->container['transport_unit_size'] = $transport_unit_size; + + return $this; + } + + /** + * Gets quantum_of_supply + * + * @return int|null + */ + public function getQuantumOfSupply() + { + return $this->container['quantum_of_supply']; + } + + /** + * Sets quantum_of_supply + * + * @param int|null $quantum_of_supply Добавочная партия: по сколько единиц товара можно добавлять к минимальному количеству minShipment. Например, если вы поставляете детское питание партиями минимум по 10 коробок и хотите добавлять к минимальной партии по 2 коробки, а в каждой коробке по 6 баночек, укажите значение 12. + * + * @return self + */ + public function setQuantumOfSupply($quantum_of_supply) + { + if (is_null($quantum_of_supply)) { + throw new \InvalidArgumentException('non-nullable quantum_of_supply cannot be null'); + } + $this->container['quantum_of_supply'] = $quantum_of_supply; + + return $this; + } + + /** + * Gets delivery_duration_days + * + * @return int|null + */ + public function getDeliveryDurationDays() + { + return $this->container['delivery_duration_days']; + } + + /** + * Sets delivery_duration_days + * + * @param int|null $delivery_duration_days Срок, за который продавец поставляет товары на склад, в днях. + * + * @return self + */ + public function setDeliveryDurationDays($delivery_duration_days) + { + if (is_null($delivery_duration_days)) { + throw new \InvalidArgumentException('non-nullable delivery_duration_days cannot be null'); + } + $this->container['delivery_duration_days'] = $delivery_duration_days; + + return $this; + } + + /** + * Gets box_count + * + * @return int|null + */ + public function getBoxCount() + { + return $this->container['box_count']; + } + + /** + * Sets box_count + * + * @param int|null $box_count Сколько мест (если больше одного) занимает товар. Параметр указывается, только если товар занимает больше одного места (например, кондиционер занимает два места: внешний и внутренний блоки в двух коробках). Если товар занимает одно место, не указывайте этот параметр. + * + * @return self + */ + public function setBoxCount($box_count) + { + if (is_null($box_count)) { + throw new \InvalidArgumentException('non-nullable box_count cannot be null'); + } + $this->container['box_count'] = $box_count; + + return $this; + } + + /** + * Gets customs_commodity_codes + * + * @return string[]|null + */ + public function getCustomsCommodityCodes() + { + return $this->container['customs_commodity_codes']; + } + + /** + * Sets customs_commodity_codes + * + * @param string[]|null $customs_commodity_codes Список кодов товара в единой Товарной номенклатуре внешнеэкономической деятельности (ТН ВЭД). Обязательный параметр, если товар подлежит особому учету (например, в системе «Меркурий» как продукция животного происхождения или в системе «Честный ЗНАК»). Может содержать только один вложенный код ТН ВЭД. + * + * @return self + */ + public function setCustomsCommodityCodes($customs_commodity_codes) + { + if (is_null($customs_commodity_codes)) { + array_push($this->openAPINullablesSetToNull, 'customs_commodity_codes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('customs_commodity_codes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['customs_commodity_codes'] = $customs_commodity_codes; + + return $this; + } + + /** + * Gets weight_dimensions + * + * @return \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null + */ + public function getWeightDimensions() + { + return $this->container['weight_dimensions']; + } + + /** + * Sets weight_dimensions + * + * @param \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null $weight_dimensions weight_dimensions + * + * @return self + */ + public function setWeightDimensions($weight_dimensions) + { + if (is_null($weight_dimensions)) { + throw new \InvalidArgumentException('non-nullable weight_dimensions cannot be null'); + } + $this->container['weight_dimensions'] = $weight_dimensions; + + return $this; + } + + /** + * Gets supply_schedule_days + * + * @return \OpenAPI\Client\Model\DayOfWeekType[]|null + */ + public function getSupplyScheduleDays() + { + return $this->container['supply_schedule_days']; + } + + /** + * Sets supply_schedule_days + * + * @param \OpenAPI\Client\Model\DayOfWeekType[]|null $supply_schedule_days Дни недели, в которые продавец поставляет товары на склад. + * + * @return self + */ + public function setSupplyScheduleDays($supply_schedule_days) + { + if (is_null($supply_schedule_days)) { + array_push($this->openAPINullablesSetToNull, 'supply_schedule_days'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('supply_schedule_days', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['supply_schedule_days'] = $supply_schedule_days; + + return $this; + } + + /** + * Gets shelf_life_days + * + * @return int|null + */ + public function getShelfLifeDays() + { + return $this->container['shelf_life_days']; + } + + /** + * Sets shelf_life_days + * + * @param int|null $shelf_life_days {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `shelfLife`. Совместное использование обоих параметров приведет к ошибке. {% endnote %} Срок годности: через сколько дней товар станет непригоден для использования. + * + * @return self + */ + public function setShelfLifeDays($shelf_life_days) + { + if (is_null($shelf_life_days)) { + throw new \InvalidArgumentException('non-nullable shelf_life_days cannot be null'); + } + $this->container['shelf_life_days'] = $shelf_life_days; + + return $this; + } + + /** + * Gets life_time_days + * + * @return int|null + */ + public function getLifeTimeDays() + { + return $this->container['life_time_days']; + } + + /** + * Sets life_time_days + * + * @param int|null $life_time_days {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `lifeTime`. Совместное использование обоих параметров приведет к ошибке. {% endnote %} Срок службы: сколько дней товар будет исправно выполнять свою функцию, а изготовитель — нести ответственность за его существенные недостатки. + * + * @return self + */ + public function setLifeTimeDays($life_time_days) + { + if (is_null($life_time_days)) { + throw new \InvalidArgumentException('non-nullable life_time_days cannot be null'); + } + $this->container['life_time_days'] = $life_time_days; + + return $this; + } + + /** + * Gets guarantee_period_days + * + * @return int|null + */ + public function getGuaranteePeriodDays() + { + return $this->container['guarantee_period_days']; + } + + /** + * Sets guarantee_period_days + * + * @param int|null $guarantee_period_days Гарантийный срок товара: сколько дней возможно обслуживание и ремонт товара или возврат денег, а изготовитель или продавец будет нести ответственность за недостатки товара. + * + * @return self + */ + public function setGuaranteePeriodDays($guarantee_period_days) + { + if (is_null($guarantee_period_days)) { + throw new \InvalidArgumentException('non-nullable guarantee_period_days cannot be null'); + } + $this->container['guarantee_period_days'] = $guarantee_period_days; + + return $this; + } + + /** + * Gets processing_state + * + * @return \OpenAPI\Client\Model\OfferProcessingStateDTO|null + */ + public function getProcessingState() + { + return $this->container['processing_state']; + } + + /** + * Sets processing_state + * + * @param \OpenAPI\Client\Model\OfferProcessingStateDTO|null $processing_state processing_state + * + * @return self + */ + public function setProcessingState($processing_state) + { + if (is_null($processing_state)) { + throw new \InvalidArgumentException('non-nullable processing_state cannot be null'); + } + $this->container['processing_state'] = $processing_state; + + return $this; + } + + /** + * Gets availability + * + * @return \OpenAPI\Client\Model\OfferAvailabilityStatusType|null + */ + public function getAvailability() + { + return $this->container['availability']; + } + + /** + * Sets availability + * + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType|null $availability availability + * + * @return self + */ + public function setAvailability($availability) + { + if (is_null($availability)) { + throw new \InvalidArgumentException('non-nullable availability cannot be null'); + } + $this->container['availability'] = $availability; + + return $this; + } + + /** + * Gets shelf_life + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getShelfLife() + { + return $this->container['shelf_life']; + } + + /** + * Sets shelf_life + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $shelf_life shelf_life + * + * @return self + */ + public function setShelfLife($shelf_life) + { + if (is_null($shelf_life)) { + throw new \InvalidArgumentException('non-nullable shelf_life cannot be null'); + } + $this->container['shelf_life'] = $shelf_life; + + return $this; + } + + /** + * Gets life_time + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getLifeTime() + { + return $this->container['life_time']; + } + + /** + * Sets life_time + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $life_time life_time + * + * @return self + */ + public function setLifeTime($life_time) + { + if (is_null($life_time)) { + throw new \InvalidArgumentException('non-nullable life_time cannot be null'); + } + $this->container['life_time'] = $life_time; + + return $this; + } + + /** + * Gets guarantee_period + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getGuaranteePeriod() + { + return $this->container['guarantee_period']; + } + + /** + * Sets guarantee_period + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $guarantee_period guarantee_period + * + * @return self + */ + public function setGuaranteePeriod($guarantee_period) + { + if (is_null($guarantee_period)) { + throw new \InvalidArgumentException('non-nullable guarantee_period cannot be null'); + } + $this->container['guarantee_period'] = $guarantee_period; + + return $this; + } + + /** + * Gets certificate + * + * @return string|null + */ + public function getCertificate() + { + return $this->container['certificate']; + } + + /** + * Sets certificate + * + * @param string|null $certificate Номер документа на товар. Перед указанием номера документ нужно загрузить в кабинете продавца на Маркете. [Инструкция](https://yandex.ru/support/marketplace/assortment/restrictions/certificates.html) + * + * @return self + */ + public function setCertificate($certificate) + { + if (is_null($certificate)) { + throw new \InvalidArgumentException('non-nullable certificate cannot be null'); + } + $this->container['certificate'] = $certificate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/MaxSaleQuantumDTO.php b/erp24/lib/yandex_market_api/Model/MaxSaleQuantumDTO.php new file mode 100644 index 00000000..d7ba8297 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/MaxSaleQuantumDTO.php @@ -0,0 +1,481 @@ + + */ +class MaxSaleQuantumDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'MaxSaleQuantumDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'max_sale_quantum' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'max_sale_quantum' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'max_sale_quantum' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'max_sale_quantum' => 'maxSaleQuantum' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'max_sale_quantum' => 'setMaxSaleQuantum' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'max_sale_quantum' => 'getMaxSaleQuantum' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('max_sale_quantum', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор категории. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название категории. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets max_sale_quantum + * + * @return int|null + */ + public function getMaxSaleQuantum() + { + return $this->container['max_sale_quantum']; + } + + /** + * Sets max_sale_quantum + * + * @param int|null $max_sale_quantum Лимит на установку кванта и минимального количества товаров. + * + * @return self + */ + public function setMaxSaleQuantum($max_sale_quantum) + { + if (is_null($max_sale_quantum)) { + throw new \InvalidArgumentException('non-nullable max_sale_quantum cannot be null'); + } + $this->container['max_sale_quantum'] = $max_sale_quantum; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/MechanicsType.php b/erp24/lib/yandex_market_api/Model/MechanicsType.php new file mode 100644 index 00000000..a9eab8e9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/MechanicsType.php @@ -0,0 +1,66 @@ + + */ +class ModelDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ModelDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'prices' => '\OpenAPI\Client\Model\ModelPriceDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'prices' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'prices' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'prices' => 'prices' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'prices' => 'setPrices' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'prices' => 'getPrices' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('prices', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор модели товара. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название модели товара. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets prices + * + * @return \OpenAPI\Client\Model\ModelPriceDTO|null + */ + public function getPrices() + { + return $this->container['prices']; + } + + /** + * Sets prices + * + * @param \OpenAPI\Client\Model\ModelPriceDTO|null $prices prices + * + * @return self + */ + public function setPrices($prices) + { + if (is_null($prices)) { + throw new \InvalidArgumentException('non-nullable prices cannot be null'); + } + $this->container['prices'] = $prices; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ModelInterface.php b/erp24/lib/yandex_market_api/Model/ModelInterface.php new file mode 100644 index 00000000..5b39de75 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ModelInterface.php @@ -0,0 +1,111 @@ + + */ +class ModelOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ModelOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'discount' => 'int', + 'name' => 'string', + 'pos' => 'int', + 'pre_discount_price' => 'float', + 'price' => 'float', + 'region_id' => 'int', + 'shipping_cost' => 'float', + 'shop_name' => 'string', + 'shop_rating' => 'int', + 'in_stock' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'discount' => 'int32', + 'name' => null, + 'pos' => 'int32', + 'pre_discount_price' => null, + 'price' => null, + 'region_id' => 'int64', + 'shipping_cost' => null, + 'shop_name' => null, + 'shop_rating' => 'int32', + 'in_stock' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'discount' => false, + 'name' => false, + 'pos' => false, + 'pre_discount_price' => false, + 'price' => false, + 'region_id' => false, + 'shipping_cost' => false, + 'shop_name' => false, + 'shop_rating' => false, + 'in_stock' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'discount' => 'discount', + 'name' => 'name', + 'pos' => 'pos', + 'pre_discount_price' => 'preDiscountPrice', + 'price' => 'price', + 'region_id' => 'regionId', + 'shipping_cost' => 'shippingCost', + 'shop_name' => 'shopName', + 'shop_rating' => 'shopRating', + 'in_stock' => 'inStock' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'discount' => 'setDiscount', + 'name' => 'setName', + 'pos' => 'setPos', + 'pre_discount_price' => 'setPreDiscountPrice', + 'price' => 'setPrice', + 'region_id' => 'setRegionId', + 'shipping_cost' => 'setShippingCost', + 'shop_name' => 'setShopName', + 'shop_rating' => 'setShopRating', + 'in_stock' => 'setInStock' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'discount' => 'getDiscount', + 'name' => 'getName', + 'pos' => 'getPos', + 'pre_discount_price' => 'getPreDiscountPrice', + 'price' => 'getPrice', + 'region_id' => 'getRegionId', + 'shipping_cost' => 'getShippingCost', + 'shop_name' => 'getShopName', + 'shop_rating' => 'getShopRating', + 'in_stock' => 'getInStock' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('discount', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('pos', $data ?? [], null); + $this->setIfExists('pre_discount_price', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('region_id', $data ?? [], null); + $this->setIfExists('shipping_cost', $data ?? [], null); + $this->setIfExists('shop_name', $data ?? [], null); + $this->setIfExists('shop_rating', $data ?? [], null); + $this->setIfExists('in_stock', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets discount + * + * @return int|null + */ + public function getDiscount() + { + return $this->container['discount']; + } + + /** + * Sets discount + * + * @param int|null $discount Скидка на предложение в процентах. + * + * @return self + */ + public function setDiscount($discount) + { + if (is_null($discount)) { + throw new \InvalidArgumentException('non-nullable discount cannot be null'); + } + $this->container['discount'] = $discount; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Наименование предложения. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets pos + * + * @return int|null + */ + public function getPos() + { + return $this->container['pos']; + } + + /** + * Sets pos + * + * @param int|null $pos Позиция предложения в выдаче Маркета на карточке модели. + * + * @return self + */ + public function setPos($pos) + { + if (is_null($pos)) { + throw new \InvalidArgumentException('non-nullable pos cannot be null'); + } + $this->container['pos'] = $pos; + + return $this; + } + + /** + * Gets pre_discount_price + * + * @return float|null + */ + public function getPreDiscountPrice() + { + return $this->container['pre_discount_price']; + } + + /** + * Sets pre_discount_price + * + * @param float|null $pre_discount_price Цена предложения без скидки магазина. + * + * @return self + */ + public function setPreDiscountPrice($pre_discount_price) + { + if (is_null($pre_discount_price)) { + throw new \InvalidArgumentException('non-nullable pre_discount_price cannot be null'); + } + $this->container['pre_discount_price'] = $pre_discount_price; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price Цена предложения без скидки, которую получает покупатель при оплате через Yandex Pay. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets region_id + * + * @return int|null + */ + public function getRegionId() + { + return $this->container['region_id']; + } + + /** + * Sets region_id + * + * @param int|null $region_id Идентификатор региона предложения (регион, откуда доставляется товар). Сначала показываются предложения, доставляемые из региона, указанного в запросе в параметре `regionId`. Предложения, доставляемые из других регионов, показываются после них. + * + * @return self + */ + public function setRegionId($region_id) + { + if (is_null($region_id)) { + throw new \InvalidArgumentException('non-nullable region_id cannot be null'); + } + $this->container['region_id'] = $region_id; + + return $this; + } + + /** + * Gets shipping_cost + * + * @return float|null + */ + public function getShippingCost() + { + return $this->container['shipping_cost']; + } + + /** + * Sets shipping_cost + * + * @param float|null $shipping_cost Стоимость доставки товара в регион: * `0` — доставка осуществляется бесплатно. * `-1` — магазин не осуществляет доставку этого товара (самовывоз). Если стоимость доставки неизвестна, параметр не выводится. + * + * @return self + */ + public function setShippingCost($shipping_cost) + { + if (is_null($shipping_cost)) { + throw new \InvalidArgumentException('non-nullable shipping_cost cannot be null'); + } + $this->container['shipping_cost'] = $shipping_cost; + + return $this; + } + + /** + * Gets shop_name + * + * @return string|null + */ + public function getShopName() + { + return $this->container['shop_name']; + } + + /** + * Sets shop_name + * + * @param string|null $shop_name Название магазина (в том виде, в котором отображается на Маркете). + * + * @return self + */ + public function setShopName($shop_name) + { + if (is_null($shop_name)) { + throw new \InvalidArgumentException('non-nullable shop_name cannot be null'); + } + $this->container['shop_name'] = $shop_name; + + return $this; + } + + /** + * Gets shop_rating + * + * @return int|null + */ + public function getShopRating() + { + return $this->container['shop_rating']; + } + + /** + * Sets shop_rating + * + * @param int|null $shop_rating Рейтинг магазина. Возможные значения: * `-1` — у магазинов, недавно появившихся на Маркете, рейтинг появляется не сразу. До момента появления рейтинга для таких магазинов возвращается значение `-1`. * `1`. * `2`. * `3`. * `4`. * `5`. + * + * @return self + */ + public function setShopRating($shop_rating) + { + if (is_null($shop_rating)) { + throw new \InvalidArgumentException('non-nullable shop_rating cannot be null'); + } + $this->container['shop_rating'] = $shop_rating; + + return $this; + } + + /** + * Gets in_stock + * + * @return int|null + * @deprecated + */ + public function getInStock() + { + return $this->container['in_stock']; + } + + /** + * Sets in_stock + * + * @param int|null $in_stock {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} + * + * @return self + * @deprecated + */ + public function setInStock($in_stock) + { + if (is_null($in_stock)) { + throw new \InvalidArgumentException('non-nullable in_stock cannot be null'); + } + $this->container['in_stock'] = $in_stock; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ModelPriceDTO.php b/erp24/lib/yandex_market_api/Model/ModelPriceDTO.php new file mode 100644 index 00000000..2bb82e40 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ModelPriceDTO.php @@ -0,0 +1,478 @@ + + */ +class ModelPriceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ModelPriceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'avg' => 'float', + 'max' => 'float', + 'min' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'avg' => null, + 'max' => null, + 'min' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'avg' => false, + 'max' => false, + 'min' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'avg' => 'avg', + 'max' => 'max', + 'min' => 'min' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'avg' => 'setAvg', + 'max' => 'setMax', + 'min' => 'setMin' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'avg' => 'getAvg', + 'max' => 'getMax', + 'min' => 'getMin' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('avg', $data ?? [], null); + $this->setIfExists('max', $data ?? [], null); + $this->setIfExists('min', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets avg + * + * @return float|null + */ + public function getAvg() + { + return $this->container['avg']; + } + + /** + * Sets avg + * + * @param float|null $avg Средняя цена предложения для модели в регионе. + * + * @return self + */ + public function setAvg($avg) + { + if (is_null($avg)) { + throw new \InvalidArgumentException('non-nullable avg cannot be null'); + } + $this->container['avg'] = $avg; + + return $this; + } + + /** + * Gets max + * + * @return float|null + */ + public function getMax() + { + return $this->container['max']; + } + + /** + * Sets max + * + * @param float|null $max Максимальная цена предложения для модели в регионе. + * + * @return self + */ + public function setMax($max) + { + if (is_null($max)) { + throw new \InvalidArgumentException('non-nullable max cannot be null'); + } + $this->container['max'] = $max; + + return $this; + } + + /** + * Gets min + * + * @return float|null + */ + public function getMin() + { + return $this->container['min']; + } + + /** + * Sets min + * + * @param float|null $min Минимальная цена предложения для модели в регионе. + * + * @return self + */ + public function setMin($min) + { + if (is_null($min)) { + throw new \InvalidArgumentException('non-nullable min cannot be null'); + } + $this->container['min'] = $min; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ModelsDTO.php b/erp24/lib/yandex_market_api/Model/ModelsDTO.php new file mode 100644 index 00000000..b6b260d2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ModelsDTO.php @@ -0,0 +1,413 @@ + + */ +class ModelsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ModelsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'models' => '\OpenAPI\Client\Model\ModelDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'models' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'models' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'models' => 'models' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'models' => 'setModels' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'models' => 'getModels' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('models', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['models'] === null) { + $invalidProperties[] = "'models' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets models + * + * @return \OpenAPI\Client\Model\ModelDTO[] + */ + public function getModels() + { + return $this->container['models']; + } + + /** + * Sets models + * + * @param \OpenAPI\Client\Model\ModelDTO[] $models Список моделей товаров. + * + * @return self + */ + public function setModels($models) + { + if (is_null($models)) { + throw new \InvalidArgumentException('non-nullable models cannot be null'); + } + $this->container['models'] = $models; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferAvailabilityStatusType.php b/erp24/lib/yandex_market_api/Model/OfferAvailabilityStatusType.php new file mode 100644 index 00000000..cc28272f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferAvailabilityStatusType.php @@ -0,0 +1,66 @@ + + */ +class OfferCampaignStatusDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferCampaignStatusDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'status' => '\OpenAPI\Client\Model\OfferCampaignStatusType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'status' => 'getStatus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор кампании. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OfferCampaignStatusType + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OfferCampaignStatusType $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferCampaignStatusType.php b/erp24/lib/yandex_market_api/Model/OfferCampaignStatusType.php new file mode 100644 index 00000000..b8450fb4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferCampaignStatusType.php @@ -0,0 +1,84 @@ + + */ +class OfferCardDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferCardDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'mapping' => '\OpenAPI\Client\Model\GetMappingDTO', + 'parameter_values' => '\OpenAPI\Client\Model\ParameterValueDTO[]', + 'card_status' => '\OpenAPI\Client\Model\OfferCardStatusType', + 'content_rating' => 'int', + 'recommendations' => '\OpenAPI\Client\Model\OfferCardRecommendationDTO[]', + 'errors' => '\OpenAPI\Client\Model\OfferErrorDTO[]', + 'warnings' => '\OpenAPI\Client\Model\OfferErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'mapping' => null, + 'parameter_values' => null, + 'card_status' => null, + 'content_rating' => 'int32', + 'recommendations' => null, + 'errors' => null, + 'warnings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'mapping' => false, + 'parameter_values' => true, + 'card_status' => false, + 'content_rating' => false, + 'recommendations' => true, + 'errors' => true, + 'warnings' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'mapping' => 'mapping', + 'parameter_values' => 'parameterValues', + 'card_status' => 'cardStatus', + 'content_rating' => 'contentRating', + 'recommendations' => 'recommendations', + 'errors' => 'errors', + 'warnings' => 'warnings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'mapping' => 'setMapping', + 'parameter_values' => 'setParameterValues', + 'card_status' => 'setCardStatus', + 'content_rating' => 'setContentRating', + 'recommendations' => 'setRecommendations', + 'errors' => 'setErrors', + 'warnings' => 'setWarnings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'mapping' => 'getMapping', + 'parameter_values' => 'getParameterValues', + 'card_status' => 'getCardStatus', + 'content_rating' => 'getContentRating', + 'recommendations' => 'getRecommendations', + 'errors' => 'getErrors', + 'warnings' => 'getWarnings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('mapping', $data ?? [], null); + $this->setIfExists('parameter_values', $data ?? [], null); + $this->setIfExists('card_status', $data ?? [], null); + $this->setIfExists('content_rating', $data ?? [], null); + $this->setIfExists('recommendations', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferCardDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferCardDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling OfferCardDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets mapping + * + * @return \OpenAPI\Client\Model\GetMappingDTO|null + */ + public function getMapping() + { + return $this->container['mapping']; + } + + /** + * Sets mapping + * + * @param \OpenAPI\Client\Model\GetMappingDTO|null $mapping mapping + * + * @return self + */ + public function setMapping($mapping) + { + if (is_null($mapping)) { + throw new \InvalidArgumentException('non-nullable mapping cannot be null'); + } + $this->container['mapping'] = $mapping; + + return $this; + } + + /** + * Gets parameter_values + * + * @return \OpenAPI\Client\Model\ParameterValueDTO[]|null + */ + public function getParameterValues() + { + return $this->container['parameter_values']; + } + + /** + * Sets parameter_values + * + * @param \OpenAPI\Client\Model\ParameterValueDTO[]|null $parameter_values Список характеристик с их значениями. + * + * @return self + */ + public function setParameterValues($parameter_values) + { + if (is_null($parameter_values)) { + array_push($this->openAPINullablesSetToNull, 'parameter_values'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('parameter_values', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['parameter_values'] = $parameter_values; + + return $this; + } + + /** + * Gets card_status + * + * @return \OpenAPI\Client\Model\OfferCardStatusType|null + */ + public function getCardStatus() + { + return $this->container['card_status']; + } + + /** + * Sets card_status + * + * @param \OpenAPI\Client\Model\OfferCardStatusType|null $card_status card_status + * + * @return self + */ + public function setCardStatus($card_status) + { + if (is_null($card_status)) { + throw new \InvalidArgumentException('non-nullable card_status cannot be null'); + } + $this->container['card_status'] = $card_status; + + return $this; + } + + /** + * Gets content_rating + * + * @return int|null + */ + public function getContentRating() + { + return $this->container['content_rating']; + } + + /** + * Sets content_rating + * + * @param int|null $content_rating Процент заполненности карточки. + * + * @return self + */ + public function setContentRating($content_rating) + { + if (is_null($content_rating)) { + throw new \InvalidArgumentException('non-nullable content_rating cannot be null'); + } + $this->container['content_rating'] = $content_rating; + + return $this; + } + + /** + * Gets recommendations + * + * @return \OpenAPI\Client\Model\OfferCardRecommendationDTO[]|null + */ + public function getRecommendations() + { + return $this->container['recommendations']; + } + + /** + * Sets recommendations + * + * @param \OpenAPI\Client\Model\OfferCardRecommendationDTO[]|null $recommendations Список рекомендаций к заполнению карточки. Рекомендации Маркета помогают заполнять карточку так, чтобы покупателям было проще найти ваш товар и решиться на покупку. + * + * @return self + */ + public function setRecommendations($recommendations) + { + if (is_null($recommendations)) { + array_push($this->openAPINullablesSetToNull, 'recommendations'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('recommendations', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['recommendations'] = $recommendations; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\OfferErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\OfferErrorDTO[]|null $errors Ошибки в контенте, препятствующие размещению товара на витрине. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + + /** + * Gets warnings + * + * @return \OpenAPI\Client\Model\OfferErrorDTO[]|null + */ + public function getWarnings() + { + return $this->container['warnings']; + } + + /** + * Sets warnings + * + * @param \OpenAPI\Client\Model\OfferErrorDTO[]|null $warnings Связанные с контентом предупреждения, не препятствующие размещению товара на витрине. + * + * @return self + */ + public function setWarnings($warnings) + { + if (is_null($warnings)) { + array_push($this->openAPINullablesSetToNull, 'warnings'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('warnings', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['warnings'] = $warnings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferCardRecommendationDTO.php b/erp24/lib/yandex_market_api/Model/OfferCardRecommendationDTO.php new file mode 100644 index 00000000..5095ca0e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferCardRecommendationDTO.php @@ -0,0 +1,463 @@ + + */ +class OfferCardRecommendationDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferCardRecommendationDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OfferCardRecommendationType', + 'percent' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'percent' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'percent' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'percent' => 'percent' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'percent' => 'setPercent' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'percent' => 'getPercent' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('percent', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if (!is_null($this->container['percent']) && ($this->container['percent'] >= 100)) { + $invalidProperties[] = "invalid value for 'percent', must be smaller than 100."; + } + + if (!is_null($this->container['percent']) && ($this->container['percent'] < 0)) { + $invalidProperties[] = "invalid value for 'percent', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OfferCardRecommendationType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OfferCardRecommendationType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets percent + * + * @return int|null + */ + public function getPercent() + { + return $this->container['percent']; + } + + /** + * Sets percent + * + * @param int|null $percent Процент выполнения рекомендации. Указывается для рекомендаций некоторых типов. + * + * @return self + */ + public function setPercent($percent) + { + if (is_null($percent)) { + throw new \InvalidArgumentException('non-nullable percent cannot be null'); + } + + if (($percent >= 100)) { + throw new \InvalidArgumentException('invalid value for $percent when calling OfferCardRecommendationDTO., must be smaller than 100.'); + } + if (($percent < 0)) { + throw new \InvalidArgumentException('invalid value for $percent when calling OfferCardRecommendationDTO., must be bigger than or equal to 0.'); + } + + $this->container['percent'] = $percent; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferCardRecommendationType.php b/erp24/lib/yandex_market_api/Model/OfferCardRecommendationType.php new file mode 100644 index 00000000..19e36bc3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferCardRecommendationType.php @@ -0,0 +1,108 @@ + + */ +class OfferCardsContentStatusDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferCardsContentStatusDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_cards' => '\OpenAPI\Client\Model\OfferCardDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_cards' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_cards' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_cards' => 'offerCards', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_cards' => 'setOfferCards', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_cards' => 'getOfferCards', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_cards', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_cards'] === null) { + $invalidProperties[] = "'offer_cards' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_cards + * + * @return \OpenAPI\Client\Model\OfferCardDTO[] + */ + public function getOfferCards() + { + return $this->container['offer_cards']; + } + + /** + * Sets offer_cards + * + * @param \OpenAPI\Client\Model\OfferCardDTO[] $offer_cards Страница списка товаров с информацией о состоянии карточек. + * + * @return self + */ + public function setOfferCards($offer_cards) + { + if (is_null($offer_cards)) { + throw new \InvalidArgumentException('non-nullable offer_cards cannot be null'); + } + $this->container['offer_cards'] = $offer_cards; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferConditionDTO.php b/erp24/lib/yandex_market_api/Model/OfferConditionDTO.php new file mode 100644 index 00000000..59d5ad21 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferConditionDTO.php @@ -0,0 +1,478 @@ + + */ +class OfferConditionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferConditionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OfferConditionType', + 'quality' => '\OpenAPI\Client\Model\OfferConditionQualityType', + 'reason' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'quality' => null, + 'reason' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'quality' => false, + 'reason' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'quality' => 'quality', + 'reason' => 'reason' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'quality' => 'setQuality', + 'reason' => 'setReason' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'quality' => 'getQuality', + 'reason' => 'getReason' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('quality', $data ?? [], null); + $this->setIfExists('reason', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OfferConditionType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OfferConditionType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets quality + * + * @return \OpenAPI\Client\Model\OfferConditionQualityType|null + */ + public function getQuality() + { + return $this->container['quality']; + } + + /** + * Sets quality + * + * @param \OpenAPI\Client\Model\OfferConditionQualityType|null $quality quality + * + * @return self + */ + public function setQuality($quality) + { + if (is_null($quality)) { + throw new \InvalidArgumentException('non-nullable quality cannot be null'); + } + $this->container['quality'] = $quality; + + return $this; + } + + /** + * Gets reason + * + * @return string|null + */ + public function getReason() + { + return $this->container['reason']; + } + + /** + * Sets reason + * + * @param string|null $reason Описание товара. Подробно опишите дефекты, насколько они заметны и где их искать. + * + * @return self + */ + public function setReason($reason) + { + if (is_null($reason)) { + throw new \InvalidArgumentException('non-nullable reason cannot be null'); + } + $this->container['reason'] = $reason; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferConditionQualityType.php b/erp24/lib/yandex_market_api/Model/OfferConditionQualityType.php new file mode 100644 index 00000000..c321b387 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferConditionQualityType.php @@ -0,0 +1,69 @@ + + */ +class OfferContentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferContentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'category_id' => 'int', + 'parameter_values' => '\OpenAPI\Client\Model\ParameterValueDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'category_id' => 'int32', + 'parameter_values' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'category_id' => false, + 'parameter_values' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'category_id' => 'categoryId', + 'parameter_values' => 'parameterValues' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'category_id' => 'setCategoryId', + 'parameter_values' => 'setParameterValues' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'category_id' => 'getCategoryId', + 'parameter_values' => 'getParameterValues' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('category_id', $data ?? [], null); + $this->setIfExists('parameter_values', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['category_id'] === null) { + $invalidProperties[] = "'category_id' can't be null"; + } + if (($this->container['category_id'] < 1)) { + $invalidProperties[] = "invalid value for 'category_id', must be bigger than or equal to 1."; + } + + if ($this->container['parameter_values'] === null) { + $invalidProperties[] = "'parameter_values' can't be null"; + } + if ((count($this->container['parameter_values']) > 300)) { + $invalidProperties[] = "invalid value for 'parameter_values', number of items must be less than or equal to 300."; + } + + if ((count($this->container['parameter_values']) < 1)) { + $invalidProperties[] = "invalid value for 'parameter_values', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferContentDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferContentDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling OfferContentDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets category_id + * + * @return int + */ + public function getCategoryId() + { + return $this->container['category_id']; + } + + /** + * Sets category_id + * + * @param int $category_id Идентификатор категории на Маркете. Чтобы узнать идентификатор категории, к которой относится товар, воспользуйтесь запросом [POST categories/tree](../../reference/categories/getCategoriesTree.md). + * + * @return self + */ + public function setCategoryId($category_id) + { + if (is_null($category_id)) { + throw new \InvalidArgumentException('non-nullable category_id cannot be null'); + } + + if (($category_id < 1)) { + throw new \InvalidArgumentException('invalid value for $category_id when calling OfferContentDTO., must be bigger than or equal to 1.'); + } + + $this->container['category_id'] = $category_id; + + return $this; + } + + /** + * Gets parameter_values + * + * @return \OpenAPI\Client\Model\ParameterValueDTO[] + */ + public function getParameterValues() + { + return $this->container['parameter_values']; + } + + /** + * Sets parameter_values + * + * @param \OpenAPI\Client\Model\ParameterValueDTO[] $parameter_values Список характеристик с их значениями. С `parameterValues` обязательно передавайте `marketCategoryId` — идентификатор категории на Маркете, к которой относятся указанные характеристики товара. При **изменении** характеристик передавайте только те, значение которых нужно обновить. Чтобы **удалить** значение заданной характеристики, передайте ее `parameterId` с пустым `value`. + * + * @return self + */ + public function setParameterValues($parameter_values) + { + if (is_null($parameter_values)) { + throw new \InvalidArgumentException('non-nullable parameter_values cannot be null'); + } + + if ((count($parameter_values) > 300)) { + throw new \InvalidArgumentException('invalid value for $parameter_values when calling OfferContentDTO., number of items must be less than or equal to 300.'); + } + if ((count($parameter_values) < 1)) { + throw new \InvalidArgumentException('invalid length for $parameter_values when calling OfferContentDTO., number of items must be greater than or equal to 1.'); + } + $this->container['parameter_values'] = $parameter_values; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferContentErrorDTO.php b/erp24/lib/yandex_market_api/Model/OfferContentErrorDTO.php new file mode 100644 index 00000000..7a24f50a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferContentErrorDTO.php @@ -0,0 +1,484 @@ + + */ +class OfferContentErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferContentErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OfferContentErrorType', + 'parameter_id' => 'int', + 'message' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'parameter_id' => 'int64', + 'message' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'parameter_id' => false, + 'message' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'parameter_id' => 'parameterId', + 'message' => 'message' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'parameter_id' => 'setParameterId', + 'message' => 'setMessage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'parameter_id' => 'getParameterId', + 'message' => 'getMessage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('parameter_id', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['message'] === null) { + $invalidProperties[] = "'message' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OfferContentErrorType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OfferContentErrorType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets parameter_id + * + * @return int|null + */ + public function getParameterId() + { + return $this->container['parameter_id']; + } + + /** + * Sets parameter_id + * + * @param int|null $parameter_id Идентификатор характеристики, с которой связана ошибка. + * + * @return self + */ + public function setParameterId($parameter_id) + { + if (is_null($parameter_id)) { + throw new \InvalidArgumentException('non-nullable parameter_id cannot be null'); + } + $this->container['parameter_id'] = $parameter_id; + + return $this; + } + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message Текст ошибки. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferContentErrorType.php b/erp24/lib/yandex_market_api/Model/OfferContentErrorType.php new file mode 100644 index 00000000..9ad42132 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferContentErrorType.php @@ -0,0 +1,90 @@ + + */ +class OfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'price' => 'float', + 'feed_id' => 'int', + 'id' => 'string', + 'shop_category_id' => 'string', + 'market_category_id' => 'int', + 'pre_discount_price' => 'float', + 'discount' => 'int', + 'cut_price' => 'bool', + 'url' => 'string', + 'model_id' => 'int', + 'name' => 'string', + 'currency' => '\OpenAPI\Client\Model\CurrencyType', + 'bid' => 'float', + 'cbid' => 'float', + 'fee' => 'float', + 'blocked' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'price' => null, + 'feed_id' => 'int64', + 'id' => null, + 'shop_category_id' => null, + 'market_category_id' => 'int32', + 'pre_discount_price' => null, + 'discount' => 'int32', + 'cut_price' => null, + 'url' => null, + 'model_id' => 'int64', + 'name' => null, + 'currency' => null, + 'bid' => null, + 'cbid' => null, + 'fee' => null, + 'blocked' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'price' => false, + 'feed_id' => false, + 'id' => false, + 'shop_category_id' => false, + 'market_category_id' => false, + 'pre_discount_price' => false, + 'discount' => false, + 'cut_price' => false, + 'url' => false, + 'model_id' => false, + 'name' => false, + 'currency' => false, + 'bid' => false, + 'cbid' => false, + 'fee' => false, + 'blocked' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'price' => 'price', + 'feed_id' => 'feedId', + 'id' => 'id', + 'shop_category_id' => 'shopCategoryId', + 'market_category_id' => 'marketCategoryId', + 'pre_discount_price' => 'preDiscountPrice', + 'discount' => 'discount', + 'cut_price' => 'cutPrice', + 'url' => 'url', + 'model_id' => 'modelId', + 'name' => 'name', + 'currency' => 'currency', + 'bid' => 'bid', + 'cbid' => 'cbid', + 'fee' => 'fee', + 'blocked' => 'blocked' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'price' => 'setPrice', + 'feed_id' => 'setFeedId', + 'id' => 'setId', + 'shop_category_id' => 'setShopCategoryId', + 'market_category_id' => 'setMarketCategoryId', + 'pre_discount_price' => 'setPreDiscountPrice', + 'discount' => 'setDiscount', + 'cut_price' => 'setCutPrice', + 'url' => 'setUrl', + 'model_id' => 'setModelId', + 'name' => 'setName', + 'currency' => 'setCurrency', + 'bid' => 'setBid', + 'cbid' => 'setCbid', + 'fee' => 'setFee', + 'blocked' => 'setBlocked' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'price' => 'getPrice', + 'feed_id' => 'getFeedId', + 'id' => 'getId', + 'shop_category_id' => 'getShopCategoryId', + 'market_category_id' => 'getMarketCategoryId', + 'pre_discount_price' => 'getPreDiscountPrice', + 'discount' => 'getDiscount', + 'cut_price' => 'getCutPrice', + 'url' => 'getUrl', + 'model_id' => 'getModelId', + 'name' => 'getName', + 'currency' => 'getCurrency', + 'bid' => 'getBid', + 'cbid' => 'getCbid', + 'fee' => 'getFee', + 'blocked' => 'getBlocked' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('feed_id', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('shop_category_id', $data ?? [], null); + $this->setIfExists('market_category_id', $data ?? [], null); + $this->setIfExists('pre_discount_price', $data ?? [], null); + $this->setIfExists('discount', $data ?? [], null); + $this->setIfExists('cut_price', $data ?? [], null); + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('model_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('bid', $data ?? [], null); + $this->setIfExists('cbid', $data ?? [], null); + $this->setIfExists('fee', $data ?? [], null); + $this->setIfExists('blocked', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['model_id'] === null) { + $invalidProperties[] = "'model_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price Цена предложения. До версии 2.0 партнерского API у параметра был тип String. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets feed_id + * + * @return int|null + */ + public function getFeedId() + { + return $this->container['feed_id']; + } + + /** + * Sets feed_id + * + * @param int|null $feed_id Идентификатор прайс-листа, содержащего предложение. Параметр доступен начиная с версии 2.0 партнерского API. + * + * @return self + */ + public function setFeedId($feed_id) + { + if (is_null($feed_id)) { + throw new \InvalidArgumentException('non-nullable feed_id cannot be null'); + } + $this->container['feed_id'] = $feed_id; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Идентификатор предложения из прайс-листа. Параметр выводится, если в прайс-листе задан уникальный идентификатор. Если в прайс-листе содержится несколько предложений с одинаковыми идентификаторами, параметр `id` указывается только для первого из них, для остальных параметры `id` и `feedId` не выводятся. Параметр доступен начиная с версии 2.0 партнерского API. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets shop_category_id + * + * @return string|null + */ + public function getShopCategoryId() + { + return $this->container['shop_category_id']; + } + + /** + * Sets shop_category_id + * + * @param string|null $shop_category_id Идентификатор категории предложения, указанный магазином в прайс-листе. Параметр выводится только для предложений, у которых указана категория в прайс-листе. Параметр доступен начиная с версии 2.0 партнерского API. + * + * @return self + */ + public function setShopCategoryId($shop_category_id) + { + if (is_null($shop_category_id)) { + throw new \InvalidArgumentException('non-nullable shop_category_id cannot be null'); + } + $this->container['shop_category_id'] = $shop_category_id; + + return $this; + } + + /** + * Gets market_category_id + * + * @return int|null + */ + public function getMarketCategoryId() + { + return $this->container['market_category_id']; + } + + /** + * Sets market_category_id + * + * @param int|null $market_category_id Идентификатор категории предложения в дереве категорий Маркета. Параметр доступен начиная с версии 2.0 партнерского API. + * + * @return self + */ + public function setMarketCategoryId($market_category_id) + { + if (is_null($market_category_id)) { + throw new \InvalidArgumentException('non-nullable market_category_id cannot be null'); + } + $this->container['market_category_id'] = $market_category_id; + + return $this; + } + + /** + * Gets pre_discount_price + * + * @return float|null + */ + public function getPreDiscountPrice() + { + return $this->container['pre_discount_price']; + } + + /** + * Sets pre_discount_price + * + * @param float|null $pre_discount_price Цена предложения без скидки. + * + * @return self + */ + public function setPreDiscountPrice($pre_discount_price) + { + if (is_null($pre_discount_price)) { + throw new \InvalidArgumentException('non-nullable pre_discount_price cannot be null'); + } + $this->container['pre_discount_price'] = $pre_discount_price; + + return $this; + } + + /** + * Gets discount + * + * @return int|null + */ + public function getDiscount() + { + return $this->container['discount']; + } + + /** + * Sets discount + * + * @param int|null $discount Скидка на предложение в процентах. + * + * @return self + */ + public function setDiscount($discount) + { + if (is_null($discount)) { + throw new \InvalidArgumentException('non-nullable discount cannot be null'); + } + $this->container['discount'] = $discount; + + return $this; + } + + /** + * Gets cut_price + * + * @return bool|null + */ + public function getCutPrice() + { + return $this->container['cut_price']; + } + + /** + * Sets cut_price + * + * @param bool|null $cut_price Является ли предложение уцененным: * `true` — да. * `false` — нет. Параметр доступен начиная с версии 2.58 партнерского API. + * + * @return self + */ + public function setCutPrice($cut_price) + { + if (is_null($cut_price)) { + throw new \InvalidArgumentException('non-nullable cut_price cannot be null'); + } + $this->container['cut_price'] = $cut_price; + + return $this; + } + + /** + * Gets url + * + * @return string|null + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string|null $url URL-адрес предложения на сайте магазина. + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets model_id + * + * @return int + */ + public function getModelId() + { + return $this->container['model_id']; + } + + /** + * Sets model_id + * + * @param int $model_id Идентификатор модели Маркета, с которой соотнесено предложение. Если предложение не соотнесено ни с какой карточкой модели, то параметр `modelid` содержит значение `0`. {% note info %} Идентификатор модели присутствует в URL карточки модели в виде значения параметра `product`. Например: `https://market.yandex.ru/product/13584121`. {% endnote %} + * + * @return self + */ + public function setModelId($model_id) + { + if (is_null($model_id)) { + throw new \InvalidArgumentException('non-nullable model_id cannot be null'); + } + $this->container['model_id'] = $model_id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Наименование предложения. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets currency + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets bid + * + * @return float|null + */ + public function getBid() + { + return $this->container['bid']; + } + + /** + * Sets bid + * + * @param float|null $bid {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Ставка на клик. + * + * @return self + */ + public function setBid($bid) + { + if (is_null($bid)) { + throw new \InvalidArgumentException('non-nullable bid cannot be null'); + } + $this->container['bid'] = $bid; + + return $this; + } + + /** + * Gets cbid + * + * @return float|null + */ + public function getCbid() + { + return $this->container['cbid']; + } + + /** + * Sets cbid + * + * @param float|null $cbid {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Ставка на клик. + * + * @return self + */ + public function setCbid($cbid) + { + if (is_null($cbid)) { + throw new \InvalidArgumentException('non-nullable cbid cannot be null'); + } + $this->container['cbid'] = $cbid; + + return $this; + } + + /** + * Gets fee + * + * @return float|null + */ + public function getFee() + { + return $this->container['fee']; + } + + /** + * Sets fee + * + * @param float|null $fee {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Процент комиссии на товар при продаже по CPA. + * + * @return self + */ + public function setFee($fee) + { + if (is_null($fee)) { + throw new \InvalidArgumentException('non-nullable fee cannot be null'); + } + $this->container['fee'] = $fee; + + return $this; + } + + /** + * Gets blocked + * + * @return bool|null + */ + public function getBlocked() + { + return $this->container['blocked']; + } + + /** + * Sets blocked + * + * @param bool|null $blocked Признак блокировки предложения. Возможные значения: * `false` — предложение активно, параметр не выводится. * `true` — предложение заблокировано. Параметр выводится, если предложение заблокировано и не попадает в выдачу Маркета. Это может произойти из-за отключения магазина. + * + * @return self + */ + public function setBlocked($blocked) + { + if (is_null($blocked)) { + throw new \InvalidArgumentException('non-nullable blocked cannot be null'); + } + $this->container['blocked'] = $blocked; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferErrorDTO.php b/erp24/lib/yandex_market_api/Model/OfferErrorDTO.php new file mode 100644 index 00000000..769444ef --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferErrorDTO.php @@ -0,0 +1,444 @@ + + */ +class OfferErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'message' => 'string', + 'comment' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'message' => null, + 'comment' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'message' => false, + 'comment' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message', + 'comment' => 'comment' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage', + 'comment' => 'setComment' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage', + 'comment' => 'getComment' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('comment', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message Тип ошибки. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets comment + * + * @return string|null + */ + public function getComment() + { + return $this->container['comment']; + } + + /** + * Sets comment + * + * @param string|null $comment Пояснение. + * + * @return self + */ + public function setComment($comment) + { + if (is_null($comment)) { + throw new \InvalidArgumentException('non-nullable comment cannot be null'); + } + $this->container['comment'] = $comment; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferForRecommendationDTO.php b/erp24/lib/yandex_market_api/Model/OfferForRecommendationDTO.php new file mode 100644 index 00000000..ee1e529b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferForRecommendationDTO.php @@ -0,0 +1,568 @@ + + */ +class OfferForRecommendationDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferForRecommendationDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'price' => '\OpenAPI\Client\Model\BasePriceDTO', + 'cofinance_price' => '\OpenAPI\Client\Model\GetPriceDTO', + 'competitiveness' => '\OpenAPI\Client\Model\PriceCompetitivenessType', + 'shows' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'price' => null, + 'cofinance_price' => null, + 'competitiveness' => null, + 'shows' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'price' => false, + 'cofinance_price' => false, + 'competitiveness' => false, + 'shows' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'price' => 'price', + 'cofinance_price' => 'cofinancePrice', + 'competitiveness' => 'competitiveness', + 'shows' => 'shows' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'price' => 'setPrice', + 'cofinance_price' => 'setCofinancePrice', + 'competitiveness' => 'setCompetitiveness', + 'shows' => 'setShows' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'price' => 'getPrice', + 'cofinance_price' => 'getCofinancePrice', + 'competitiveness' => 'getCompetitiveness', + 'shows' => 'getShows' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('cofinance_price', $data ?? [], null); + $this->setIfExists('competitiveness', $data ?? [], null); + $this->setIfExists('shows', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferForRecommendationDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferForRecommendationDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling OfferForRecommendationDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $price price + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets cofinance_price + * + * @return \OpenAPI\Client\Model\GetPriceDTO|null + */ + public function getCofinancePrice() + { + return $this->container['cofinance_price']; + } + + /** + * Sets cofinance_price + * + * @param \OpenAPI\Client\Model\GetPriceDTO|null $cofinance_price cofinance_price + * + * @return self + */ + public function setCofinancePrice($cofinance_price) + { + if (is_null($cofinance_price)) { + throw new \InvalidArgumentException('non-nullable cofinance_price cannot be null'); + } + $this->container['cofinance_price'] = $cofinance_price; + + return $this; + } + + /** + * Gets competitiveness + * + * @return \OpenAPI\Client\Model\PriceCompetitivenessType|null + */ + public function getCompetitiveness() + { + return $this->container['competitiveness']; + } + + /** + * Sets competitiveness + * + * @param \OpenAPI\Client\Model\PriceCompetitivenessType|null $competitiveness competitiveness + * + * @return self + */ + public function setCompetitiveness($competitiveness) + { + if (is_null($competitiveness)) { + throw new \InvalidArgumentException('non-nullable competitiveness cannot be null'); + } + $this->container['competitiveness'] = $competitiveness; + + return $this; + } + + /** + * Gets shows + * + * @return int|null + */ + public function getShows() + { + return $this->container['shows']; + } + + /** + * Sets shows + * + * @param int|null $shows Количество показов карточки товара за последние 7 дней. + * + * @return self + */ + public function setShows($shows) + { + if (is_null($shows)) { + throw new \InvalidArgumentException('non-nullable shows cannot be null'); + } + $this->container['shows'] = $shows; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferManualDTO.php b/erp24/lib/yandex_market_api/Model/OfferManualDTO.php new file mode 100644 index 00000000..71d9c94e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferManualDTO.php @@ -0,0 +1,447 @@ + + */ +class OfferManualDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferManualDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'url' => 'string', + 'title' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'url' => null, + 'title' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'url' => false, + 'title' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'url' => 'url', + 'title' => 'title' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'url' => 'setUrl', + 'title' => 'setTitle' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'url' => 'getUrl', + 'title' => 'getTitle' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('title', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['url'] === null) { + $invalidProperties[] = "'url' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets url + * + * @return string + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string $url Ссылка на инструкцию. + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets title + * + * @return string|null + */ + public function getTitle() + { + return $this->container['title']; + } + + /** + * Sets title + * + * @param string|null $title Название инструкции, которое будет отображаться на карточке товара. + * + * @return self + */ + public function setTitle($title) + { + if (is_null($title)) { + throw new \InvalidArgumentException('non-nullable title cannot be null'); + } + $this->container['title'] = $title; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferMappingDTO.php b/erp24/lib/yandex_market_api/Model/OfferMappingDTO.php new file mode 100644 index 00000000..c3fa413d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferMappingDTO.php @@ -0,0 +1,487 @@ + + */ +class OfferMappingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferMappingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'market_sku' => 'int', + 'model_id' => 'int', + 'category_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'market_sku' => 'int64', + 'model_id' => 'int64', + 'category_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'market_sku' => false, + 'model_id' => false, + 'category_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'market_sku' => 'marketSku', + 'model_id' => 'modelId', + 'category_id' => 'categoryId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'market_sku' => 'setMarketSku', + 'model_id' => 'setModelId', + 'category_id' => 'setCategoryId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'market_sku' => 'getMarketSku', + 'model_id' => 'getModelId', + 'category_id' => 'getCategoryId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('market_sku', $data ?? [], null); + $this->setIfExists('model_id', $data ?? [], null); + $this->setIfExists('category_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling OfferMappingDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + + /** + * Gets model_id + * + * @return int|null + */ + public function getModelId() + { + return $this->container['model_id']; + } + + /** + * Sets model_id + * + * @param int|null $model_id Идентификатор модели для текущей карточки товара на Маркете. Например, две лопатки разных цветов имеют разные SKU на Маркете (параметр `marketSku`), но одинаковый идентификатор модели товара. + * + * @return self + */ + public function setModelId($model_id) + { + if (is_null($model_id)) { + throw new \InvalidArgumentException('non-nullable model_id cannot be null'); + } + $this->container['model_id'] = $model_id; + + return $this; + } + + /** + * Gets category_id + * + * @return int|null + */ + public function getCategoryId() + { + return $this->container['category_id']; + } + + /** + * Sets category_id + * + * @param int|null $category_id Идентификатор категории для текущей карточки товара на Маркете. + * + * @return self + */ + public function setCategoryId($category_id) + { + if (is_null($category_id)) { + throw new \InvalidArgumentException('non-nullable category_id cannot be null'); + } + $this->container['category_id'] = $category_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferMappingEntriesDTO.php b/erp24/lib/yandex_market_api/Model/OfferMappingEntriesDTO.php new file mode 100644 index 00000000..b5282fb4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferMappingEntriesDTO.php @@ -0,0 +1,447 @@ + + */ +class OfferMappingEntriesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferMappingEntriesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'offer_mapping_entries' => '\OpenAPI\Client\Model\OfferMappingEntryDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'offer_mapping_entries' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'offer_mapping_entries' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'offer_mapping_entries' => 'offerMappingEntries' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'offer_mapping_entries' => 'setOfferMappingEntries' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'offer_mapping_entries' => 'getOfferMappingEntries' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('offer_mapping_entries', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_mapping_entries'] === null) { + $invalidProperties[] = "'offer_mapping_entries' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets offer_mapping_entries + * + * @return \OpenAPI\Client\Model\OfferMappingEntryDTO[] + */ + public function getOfferMappingEntries() + { + return $this->container['offer_mapping_entries']; + } + + /** + * Sets offer_mapping_entries + * + * @param \OpenAPI\Client\Model\OfferMappingEntryDTO[] $offer_mapping_entries Информация о товарах в каталоге. + * + * @return self + */ + public function setOfferMappingEntries($offer_mapping_entries) + { + if (is_null($offer_mapping_entries)) { + throw new \InvalidArgumentException('non-nullable offer_mapping_entries cannot be null'); + } + $this->container['offer_mapping_entries'] = $offer_mapping_entries; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferMappingEntryDTO.php b/erp24/lib/yandex_market_api/Model/OfferMappingEntryDTO.php new file mode 100644 index 00000000..feef8f4d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferMappingEntryDTO.php @@ -0,0 +1,512 @@ + + */ +class OfferMappingEntryDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferMappingEntryDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'mapping' => '\OpenAPI\Client\Model\OfferMappingDTO', + 'awaiting_moderation_mapping' => '\OpenAPI\Client\Model\OfferMappingDTO', + 'rejected_mapping' => '\OpenAPI\Client\Model\OfferMappingDTO', + 'offer' => '\OpenAPI\Client\Model\MappingsOfferDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'mapping' => null, + 'awaiting_moderation_mapping' => null, + 'rejected_mapping' => null, + 'offer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'mapping' => false, + 'awaiting_moderation_mapping' => false, + 'rejected_mapping' => false, + 'offer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'mapping' => 'mapping', + 'awaiting_moderation_mapping' => 'awaitingModerationMapping', + 'rejected_mapping' => 'rejectedMapping', + 'offer' => 'offer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'mapping' => 'setMapping', + 'awaiting_moderation_mapping' => 'setAwaitingModerationMapping', + 'rejected_mapping' => 'setRejectedMapping', + 'offer' => 'setOffer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'mapping' => 'getMapping', + 'awaiting_moderation_mapping' => 'getAwaitingModerationMapping', + 'rejected_mapping' => 'getRejectedMapping', + 'offer' => 'getOffer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('mapping', $data ?? [], null); + $this->setIfExists('awaiting_moderation_mapping', $data ?? [], null); + $this->setIfExists('rejected_mapping', $data ?? [], null); + $this->setIfExists('offer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getMapping() + { + return $this->container['mapping']; + } + + /** + * Sets mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $mapping mapping + * + * @return self + */ + public function setMapping($mapping) + { + if (is_null($mapping)) { + throw new \InvalidArgumentException('non-nullable mapping cannot be null'); + } + $this->container['mapping'] = $mapping; + + return $this; + } + + /** + * Gets awaiting_moderation_mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getAwaitingModerationMapping() + { + return $this->container['awaiting_moderation_mapping']; + } + + /** + * Sets awaiting_moderation_mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $awaiting_moderation_mapping awaiting_moderation_mapping + * + * @return self + */ + public function setAwaitingModerationMapping($awaiting_moderation_mapping) + { + if (is_null($awaiting_moderation_mapping)) { + throw new \InvalidArgumentException('non-nullable awaiting_moderation_mapping cannot be null'); + } + $this->container['awaiting_moderation_mapping'] = $awaiting_moderation_mapping; + + return $this; + } + + /** + * Gets rejected_mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getRejectedMapping() + { + return $this->container['rejected_mapping']; + } + + /** + * Sets rejected_mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $rejected_mapping rejected_mapping + * + * @return self + */ + public function setRejectedMapping($rejected_mapping) + { + if (is_null($rejected_mapping)) { + throw new \InvalidArgumentException('non-nullable rejected_mapping cannot be null'); + } + $this->container['rejected_mapping'] = $rejected_mapping; + + return $this; + } + + /** + * Gets offer + * + * @return \OpenAPI\Client\Model\MappingsOfferDTO|null + */ + public function getOffer() + { + return $this->container['offer']; + } + + /** + * Sets offer + * + * @param \OpenAPI\Client\Model\MappingsOfferDTO|null $offer offer + * + * @return self + */ + public function setOffer($offer) + { + if (is_null($offer)) { + throw new \InvalidArgumentException('non-nullable offer cannot be null'); + } + $this->container['offer'] = $offer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferMappingErrorDTO.php b/erp24/lib/yandex_market_api/Model/OfferMappingErrorDTO.php new file mode 100644 index 00000000..e25689fa --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferMappingErrorDTO.php @@ -0,0 +1,484 @@ + + */ +class OfferMappingErrorDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferMappingErrorDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OfferMappingErrorType', + 'parameter_id' => 'int', + 'message' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'parameter_id' => 'int64', + 'message' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'parameter_id' => false, + 'message' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'parameter_id' => 'parameterId', + 'message' => 'message' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'parameter_id' => 'setParameterId', + 'message' => 'setMessage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'parameter_id' => 'getParameterId', + 'message' => 'getMessage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('parameter_id', $data ?? [], null); + $this->setIfExists('message', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['message'] === null) { + $invalidProperties[] = "'message' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OfferMappingErrorType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OfferMappingErrorType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets parameter_id + * + * @return int|null + */ + public function getParameterId() + { + return $this->container['parameter_id']; + } + + /** + * Sets parameter_id + * + * @param int|null $parameter_id Идентификатор характеристики, с которой связана ошибка. + * + * @return self + */ + public function setParameterId($parameter_id) + { + if (is_null($parameter_id)) { + throw new \InvalidArgumentException('non-nullable parameter_id cannot be null'); + } + $this->container['parameter_id'] = $parameter_id; + + return $this; + } + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message Текст ошибки. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferMappingErrorType.php b/erp24/lib/yandex_market_api/Model/OfferMappingErrorType.php new file mode 100644 index 00000000..9862ca21 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferMappingErrorType.php @@ -0,0 +1,96 @@ + + */ +class OfferMappingInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferMappingInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'mapping' => '\OpenAPI\Client\Model\OfferMappingDTO', + 'awaiting_moderation_mapping' => '\OpenAPI\Client\Model\OfferMappingDTO', + 'rejected_mapping' => '\OpenAPI\Client\Model\OfferMappingDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'mapping' => null, + 'awaiting_moderation_mapping' => null, + 'rejected_mapping' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'mapping' => false, + 'awaiting_moderation_mapping' => false, + 'rejected_mapping' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'mapping' => 'mapping', + 'awaiting_moderation_mapping' => 'awaitingModerationMapping', + 'rejected_mapping' => 'rejectedMapping' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'mapping' => 'setMapping', + 'awaiting_moderation_mapping' => 'setAwaitingModerationMapping', + 'rejected_mapping' => 'setRejectedMapping' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'mapping' => 'getMapping', + 'awaiting_moderation_mapping' => 'getAwaitingModerationMapping', + 'rejected_mapping' => 'getRejectedMapping' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('mapping', $data ?? [], null); + $this->setIfExists('awaiting_moderation_mapping', $data ?? [], null); + $this->setIfExists('rejected_mapping', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getMapping() + { + return $this->container['mapping']; + } + + /** + * Sets mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $mapping mapping + * + * @return self + */ + public function setMapping($mapping) + { + if (is_null($mapping)) { + throw new \InvalidArgumentException('non-nullable mapping cannot be null'); + } + $this->container['mapping'] = $mapping; + + return $this; + } + + /** + * Gets awaiting_moderation_mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getAwaitingModerationMapping() + { + return $this->container['awaiting_moderation_mapping']; + } + + /** + * Sets awaiting_moderation_mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $awaiting_moderation_mapping awaiting_moderation_mapping + * + * @return self + */ + public function setAwaitingModerationMapping($awaiting_moderation_mapping) + { + if (is_null($awaiting_moderation_mapping)) { + throw new \InvalidArgumentException('non-nullable awaiting_moderation_mapping cannot be null'); + } + $this->container['awaiting_moderation_mapping'] = $awaiting_moderation_mapping; + + return $this; + } + + /** + * Gets rejected_mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getRejectedMapping() + { + return $this->container['rejected_mapping']; + } + + /** + * Sets rejected_mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $rejected_mapping rejected_mapping + * + * @return self + */ + public function setRejectedMapping($rejected_mapping) + { + if (is_null($rejected_mapping)) { + throw new \InvalidArgumentException('non-nullable rejected_mapping cannot be null'); + } + $this->container['rejected_mapping'] = $rejected_mapping; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferMappingKindType.php b/erp24/lib/yandex_market_api/Model/OfferMappingKindType.php new file mode 100644 index 00000000..717354ab --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferMappingKindType.php @@ -0,0 +1,63 @@ + + */ +class OfferMappingSuggestionsListDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferMappingSuggestionsListDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\EnrichedMappingsOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\EnrichedMappingsOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\EnrichedMappingsOfferDTO[] $offers Список товаров. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferParamDTO.php b/erp24/lib/yandex_market_api/Model/OfferParamDTO.php new file mode 100644 index 00000000..2af96770 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferParamDTO.php @@ -0,0 +1,450 @@ + + */ +class OfferParamDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferParamDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'value' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'value' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'value' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('value', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название. Должно совпадать с названием характеристики на Маркете. Узнать его можно из Excel-шаблона категории или через запрос [POST category/{categoryId}/parameters](../../reference/content/getCategoryContentParameters.md). + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value Значение. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferPriceByOfferIdsListResponseDTO.php b/erp24/lib/yandex_market_api/Model/OfferPriceByOfferIdsListResponseDTO.php new file mode 100644 index 00000000..e39f7d8b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferPriceByOfferIdsListResponseDTO.php @@ -0,0 +1,447 @@ + + */ +class OfferPriceByOfferIdsListResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferPriceByOfferIdsListResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\OfferPriceByOfferIdsResponseDTO[]', + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\OfferPriceByOfferIdsResponseDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\OfferPriceByOfferIdsResponseDTO[] $offers Страница списка цен. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferPriceByOfferIdsResponseDTO.php b/erp24/lib/yandex_market_api/Model/OfferPriceByOfferIdsResponseDTO.php new file mode 100644 index 00000000..e7513429 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferPriceByOfferIdsResponseDTO.php @@ -0,0 +1,500 @@ + + */ +class OfferPriceByOfferIdsResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferPriceByOfferIdsResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'price' => '\OpenAPI\Client\Model\PriceDTO', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'price' => null, + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'price' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'price' => 'price', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'price' => 'setPrice', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'price' => 'getPrice', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferPriceByOfferIdsResponseDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferPriceByOfferIdsResponseDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling OfferPriceByOfferIdsResponseDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets price + * + * @return \OpenAPI\Client\Model\PriceDTO|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param \OpenAPI\Client\Model\PriceDTO|null $price price + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at Дата и время последнего обновления цены. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferPriceDTO.php b/erp24/lib/yandex_market_api/Model/OfferPriceDTO.php new file mode 100644 index 00000000..6c95041c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferPriceDTO.php @@ -0,0 +1,466 @@ + + */ +class OfferPriceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferPriceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'price' => '\OpenAPI\Client\Model\PriceDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'price' => 'price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'price' => 'setPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'price' => 'getPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferPriceDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferPriceDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling OfferPriceDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets price + * + * @return \OpenAPI\Client\Model\PriceDTO|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param \OpenAPI\Client\Model\PriceDTO|null $price price + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferPriceListResponseDTO.php b/erp24/lib/yandex_market_api/Model/OfferPriceListResponseDTO.php new file mode 100644 index 00000000..183a4bd3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferPriceListResponseDTO.php @@ -0,0 +1,481 @@ + + */ +class OfferPriceListResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferPriceListResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\OfferPriceResponseDTO[]', + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'total' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null, + 'paging' => null, + 'total' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false, + 'paging' => false, + 'total' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers', + 'paging' => 'paging', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers', + 'paging' => 'setPaging', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers', + 'paging' => 'getPaging', + 'total' => 'getTotal' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('total', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\OfferPriceResponseDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\OfferPriceResponseDTO[] $offers Страница списка. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets total + * + * @return int|null + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param int|null $total Количество всех цен магазина, измененных через API. + * + * @return self + */ + public function setTotal($total) + { + if (is_null($total)) { + throw new \InvalidArgumentException('non-nullable total cannot be null'); + } + $this->container['total'] = $total; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferPriceResponseDTO.php b/erp24/lib/yandex_market_api/Model/OfferPriceResponseDTO.php new file mode 100644 index 00000000..be444778 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferPriceResponseDTO.php @@ -0,0 +1,521 @@ + + */ +class OfferPriceResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferPriceResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'price' => '\OpenAPI\Client\Model\PriceDTO', + 'market_sku' => 'int', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'price' => null, + 'market_sku' => 'int64', + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'price' => false, + 'market_sku' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'price' => 'price', + 'market_sku' => 'marketSku', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'price' => 'setPrice', + 'market_sku' => 'setMarketSku', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'price' => 'getPrice', + 'market_sku' => 'getMarketSku', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('market_sku', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Идентификатор предложения из прайс-листа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets price + * + * @return \OpenAPI\Client\Model\PriceDTO|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param \OpenAPI\Client\Model\PriceDTO|null $price price + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling OfferPriceResponseDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at Дата и время последнего обновления цены на товар. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferProcessingNoteDTO.php b/erp24/lib/yandex_market_api/Model/OfferProcessingNoteDTO.php new file mode 100644 index 00000000..e421dea6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferProcessingNoteDTO.php @@ -0,0 +1,444 @@ + + */ +class OfferProcessingNoteDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferProcessingNoteDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OfferProcessingNoteType', + 'payload' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'payload' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'payload' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'payload' => 'payload' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'payload' => 'setPayload' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'payload' => 'getPayload' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('payload', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OfferProcessingNoteType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OfferProcessingNoteType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets payload + * + * @return string|null + */ + public function getPayload() + { + return $this->container['payload']; + } + + /** + * Sets payload + * + * @param string|null $payload Дополнительная информация о причине отклонения товара. + * + * @return self + */ + public function setPayload($payload) + { + if (is_null($payload)) { + throw new \InvalidArgumentException('non-nullable payload cannot be null'); + } + $this->container['payload'] = $payload; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferProcessingNoteType.php b/erp24/lib/yandex_market_api/Model/OfferProcessingNoteType.php new file mode 100644 index 00000000..d1664de0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferProcessingNoteType.php @@ -0,0 +1,105 @@ + + */ +class OfferProcessingStateDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferProcessingStateDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\OfferProcessingStatusType', + 'notes' => '\OpenAPI\Client\Model\OfferProcessingNoteDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'notes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'notes' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'notes' => 'notes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'notes' => 'setNotes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'notes' => 'getNotes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('notes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OfferProcessingStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OfferProcessingStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets notes + * + * @return \OpenAPI\Client\Model\OfferProcessingNoteDTO[]|null + */ + public function getNotes() + { + return $this->container['notes']; + } + + /** + * Sets notes + * + * @param \OpenAPI\Client\Model\OfferProcessingNoteDTO[]|null $notes Причины, по которым товар не прошел модерацию. + * + * @return self + */ + public function setNotes($notes) + { + if (is_null($notes)) { + array_push($this->openAPINullablesSetToNull, 'notes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('notes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['notes'] = $notes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferProcessingStatusType.php b/erp24/lib/yandex_market_api/Model/OfferProcessingStatusType.php new file mode 100644 index 00000000..9ae995b6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferProcessingStatusType.php @@ -0,0 +1,93 @@ + + */ +class OfferRecommendationDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferRecommendationDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer' => '\OpenAPI\Client\Model\OfferForRecommendationDTO', + 'recommendation' => '\OpenAPI\Client\Model\OfferRecommendationInfoDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer' => null, + 'recommendation' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer' => false, + 'recommendation' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer' => 'offer', + 'recommendation' => 'recommendation' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer' => 'setOffer', + 'recommendation' => 'setRecommendation' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer' => 'getOffer', + 'recommendation' => 'getRecommendation' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer', $data ?? [], null); + $this->setIfExists('recommendation', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer + * + * @return \OpenAPI\Client\Model\OfferForRecommendationDTO|null + */ + public function getOffer() + { + return $this->container['offer']; + } + + /** + * Sets offer + * + * @param \OpenAPI\Client\Model\OfferForRecommendationDTO|null $offer offer + * + * @return self + */ + public function setOffer($offer) + { + if (is_null($offer)) { + throw new \InvalidArgumentException('non-nullable offer cannot be null'); + } + $this->container['offer'] = $offer; + + return $this; + } + + /** + * Gets recommendation + * + * @return \OpenAPI\Client\Model\OfferRecommendationInfoDTO|null + */ + public function getRecommendation() + { + return $this->container['recommendation']; + } + + /** + * Sets recommendation + * + * @param \OpenAPI\Client\Model\OfferRecommendationInfoDTO|null $recommendation recommendation + * + * @return self + */ + public function setRecommendation($recommendation) + { + if (is_null($recommendation)) { + throw new \InvalidArgumentException('non-nullable recommendation cannot be null'); + } + $this->container['recommendation'] = $recommendation; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferRecommendationInfoDTO.php b/erp24/lib/yandex_market_api/Model/OfferRecommendationInfoDTO.php new file mode 100644 index 00000000..d2cd508b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferRecommendationInfoDTO.php @@ -0,0 +1,500 @@ + + */ +class OfferRecommendationInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferRecommendationInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'recommended_cofinance_price' => '\OpenAPI\Client\Model\BasePriceDTO', + 'competitiveness_thresholds' => '\OpenAPI\Client\Model\PriceCompetitivenessThresholdsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'recommended_cofinance_price' => null, + 'competitiveness_thresholds' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'recommended_cofinance_price' => false, + 'competitiveness_thresholds' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'recommended_cofinance_price' => 'recommendedCofinancePrice', + 'competitiveness_thresholds' => 'competitivenessThresholds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'recommended_cofinance_price' => 'setRecommendedCofinancePrice', + 'competitiveness_thresholds' => 'setCompetitivenessThresholds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'recommended_cofinance_price' => 'getRecommendedCofinancePrice', + 'competitiveness_thresholds' => 'getCompetitivenessThresholds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('recommended_cofinance_price', $data ?? [], null); + $this->setIfExists('competitiveness_thresholds', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferRecommendationInfoDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OfferRecommendationInfoDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling OfferRecommendationInfoDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets recommended_cofinance_price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getRecommendedCofinancePrice() + { + return $this->container['recommended_cofinance_price']; + } + + /** + * Sets recommended_cofinance_price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $recommended_cofinance_price recommended_cofinance_price + * + * @return self + */ + public function setRecommendedCofinancePrice($recommended_cofinance_price) + { + if (is_null($recommended_cofinance_price)) { + throw new \InvalidArgumentException('non-nullable recommended_cofinance_price cannot be null'); + } + $this->container['recommended_cofinance_price'] = $recommended_cofinance_price; + + return $this; + } + + /** + * Gets competitiveness_thresholds + * + * @return \OpenAPI\Client\Model\PriceCompetitivenessThresholdsDTO|null + */ + public function getCompetitivenessThresholds() + { + return $this->container['competitiveness_thresholds']; + } + + /** + * Sets competitiveness_thresholds + * + * @param \OpenAPI\Client\Model\PriceCompetitivenessThresholdsDTO|null $competitiveness_thresholds competitiveness_thresholds + * + * @return self + */ + public function setCompetitivenessThresholds($competitiveness_thresholds) + { + if (is_null($competitiveness_thresholds)) { + throw new \InvalidArgumentException('non-nullable competitiveness_thresholds cannot be null'); + } + $this->container['competitiveness_thresholds'] = $competitiveness_thresholds; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferRecommendationsResultDTO.php b/erp24/lib/yandex_market_api/Model/OfferRecommendationsResultDTO.php new file mode 100644 index 00000000..184215f8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferRecommendationsResultDTO.php @@ -0,0 +1,447 @@ + + */ +class OfferRecommendationsResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferRecommendationsResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ScrollingPagerDTO', + 'offer_recommendations' => '\OpenAPI\Client\Model\OfferRecommendationDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'offer_recommendations' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'offer_recommendations' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'offer_recommendations' => 'offerRecommendations' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'offer_recommendations' => 'setOfferRecommendations' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'offer_recommendations' => 'getOfferRecommendations' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('offer_recommendations', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_recommendations'] === null) { + $invalidProperties[] = "'offer_recommendations' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets offer_recommendations + * + * @return \OpenAPI\Client\Model\OfferRecommendationDTO[] + */ + public function getOfferRecommendations() + { + return $this->container['offer_recommendations']; + } + + /** + * Sets offer_recommendations + * + * @param \OpenAPI\Client\Model\OfferRecommendationDTO[] $offer_recommendations Страница списка товаров. + * + * @return self + */ + public function setOfferRecommendations($offer_recommendations) + { + if (is_null($offer_recommendations)) { + throw new \InvalidArgumentException('non-nullable offer_recommendations cannot be null'); + } + $this->container['offer_recommendations'] = $offer_recommendations; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferSellingProgramDTO.php b/erp24/lib/yandex_market_api/Model/OfferSellingProgramDTO.php new file mode 100644 index 00000000..dfe85a6f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferSellingProgramDTO.php @@ -0,0 +1,450 @@ + + */ +class OfferSellingProgramDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferSellingProgramDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'selling_program' => '\OpenAPI\Client\Model\SellingProgramType', + 'status' => '\OpenAPI\Client\Model\OfferSellingProgramStatusType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'selling_program' => null, + 'status' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'selling_program' => false, + 'status' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'selling_program' => 'sellingProgram', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'selling_program' => 'setSellingProgram', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'selling_program' => 'getSellingProgram', + 'status' => 'getStatus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('selling_program', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['selling_program'] === null) { + $invalidProperties[] = "'selling_program' can't be null"; + } + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets selling_program + * + * @return \OpenAPI\Client\Model\SellingProgramType + */ + public function getSellingProgram() + { + return $this->container['selling_program']; + } + + /** + * Sets selling_program + * + * @param \OpenAPI\Client\Model\SellingProgramType $selling_program selling_program + * + * @return self + */ + public function setSellingProgram($selling_program) + { + if (is_null($selling_program)) { + throw new \InvalidArgumentException('non-nullable selling_program cannot be null'); + } + $this->container['selling_program'] = $selling_program; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OfferSellingProgramStatusType + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OfferSellingProgramStatusType $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OfferSellingProgramStatusType.php b/erp24/lib/yandex_market_api/Model/OfferSellingProgramStatusType.php new file mode 100644 index 00000000..60752389 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OfferSellingProgramStatusType.php @@ -0,0 +1,63 @@ + + */ +class OfferWeightDimensionsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OfferWeightDimensionsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'length' => 'float', + 'width' => 'float', + 'height' => 'float', + 'weight' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'length' => null, + 'width' => null, + 'height' => null, + 'weight' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'length' => false, + 'width' => false, + 'height' => false, + 'weight' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'length' => 'length', + 'width' => 'width', + 'height' => 'height', + 'weight' => 'weight' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'length' => 'setLength', + 'width' => 'setWidth', + 'height' => 'setHeight', + 'weight' => 'setWeight' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'length' => 'getLength', + 'width' => 'getWidth', + 'height' => 'getHeight', + 'weight' => 'getWeight' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('length', $data ?? [], null); + $this->setIfExists('width', $data ?? [], null); + $this->setIfExists('height', $data ?? [], null); + $this->setIfExists('weight', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['length'] === null) { + $invalidProperties[] = "'length' can't be null"; + } + if ($this->container['width'] === null) { + $invalidProperties[] = "'width' can't be null"; + } + if ($this->container['height'] === null) { + $invalidProperties[] = "'height' can't be null"; + } + if ($this->container['weight'] === null) { + $invalidProperties[] = "'weight' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets length + * + * @return float + */ + public function getLength() + { + return $this->container['length']; + } + + /** + * Sets length + * + * @param float $length Длина упаковки в см. + * + * @return self + */ + public function setLength($length) + { + if (is_null($length)) { + throw new \InvalidArgumentException('non-nullable length cannot be null'); + } + $this->container['length'] = $length; + + return $this; + } + + /** + * Gets width + * + * @return float + */ + public function getWidth() + { + return $this->container['width']; + } + + /** + * Sets width + * + * @param float $width Ширина упаковки в см. + * + * @return self + */ + public function setWidth($width) + { + if (is_null($width)) { + throw new \InvalidArgumentException('non-nullable width cannot be null'); + } + $this->container['width'] = $width; + + return $this; + } + + /** + * Gets height + * + * @return float + */ + public function getHeight() + { + return $this->container['height']; + } + + /** + * Sets height + * + * @param float $height Высота упаковки в см. + * + * @return self + */ + public function setHeight($height) + { + if (is_null($height)) { + throw new \InvalidArgumentException('non-nullable height cannot be null'); + } + $this->container['height'] = $height; + + return $this; + } + + /** + * Gets weight + * + * @return float + */ + public function getWeight() + { + return $this->container['weight']; + } + + /** + * Sets weight + * + * @param float $weight Вес товара в кг с учетом упаковки (брутто). + * + * @return self + */ + public function setWeight($weight) + { + if (is_null($weight)) { + throw new \InvalidArgumentException('non-nullable weight cannot be null'); + } + $this->container['weight'] = $weight; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OffersDTO.php b/erp24/lib/yandex_market_api/Model/OffersDTO.php new file mode 100644 index 00000000..3a492886 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OffersDTO.php @@ -0,0 +1,413 @@ + + */ +class OffersDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OffersDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\OfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\OfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\OfferDTO[] $offers Список предложений магазина. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OptionValuesLimitedDTO.php b/erp24/lib/yandex_market_api/Model/OptionValuesLimitedDTO.php new file mode 100644 index 00000000..57df1eb6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OptionValuesLimitedDTO.php @@ -0,0 +1,450 @@ + + */ +class OptionValuesLimitedDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OptionValuesLimitedDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'limiting_option_value_id' => 'int', + 'option_value_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'limiting_option_value_id' => 'int64', + 'option_value_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'limiting_option_value_id' => false, + 'option_value_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'limiting_option_value_id' => 'limitingOptionValueId', + 'option_value_ids' => 'optionValueIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'limiting_option_value_id' => 'setLimitingOptionValueId', + 'option_value_ids' => 'setOptionValueIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'limiting_option_value_id' => 'getLimitingOptionValueId', + 'option_value_ids' => 'getOptionValueIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('limiting_option_value_id', $data ?? [], null); + $this->setIfExists('option_value_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['limiting_option_value_id'] === null) { + $invalidProperties[] = "'limiting_option_value_id' can't be null"; + } + if ($this->container['option_value_ids'] === null) { + $invalidProperties[] = "'option_value_ids' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets limiting_option_value_id + * + * @return int + */ + public function getLimitingOptionValueId() + { + return $this->container['limiting_option_value_id']; + } + + /** + * Sets limiting_option_value_id + * + * @param int $limiting_option_value_id Идентификатор значения ограничивающей характеристики. + * + * @return self + */ + public function setLimitingOptionValueId($limiting_option_value_id) + { + if (is_null($limiting_option_value_id)) { + throw new \InvalidArgumentException('non-nullable limiting_option_value_id cannot be null'); + } + $this->container['limiting_option_value_id'] = $limiting_option_value_id; + + return $this; + } + + /** + * Gets option_value_ids + * + * @return int[] + */ + public function getOptionValueIds() + { + return $this->container['option_value_ids']; + } + + /** + * Sets option_value_ids + * + * @param int[] $option_value_ids Идентификаторы допустимых значений ограничиваемой характеристики. + * + * @return self + */ + public function setOptionValueIds($option_value_ids) + { + if (is_null($option_value_ids)) { + throw new \InvalidArgumentException('non-nullable option_value_ids cannot be null'); + } + $this->container['option_value_ids'] = $option_value_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBoxLayoutDTO.php b/erp24/lib/yandex_market_api/Model/OrderBoxLayoutDTO.php new file mode 100644 index 00000000..c5cab69b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBoxLayoutDTO.php @@ -0,0 +1,422 @@ + + */ +class OrderBoxLayoutDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBoxLayoutDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\OpenAPI\Client\Model\OrderBoxLayoutItemDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'items' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('items', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + if ((count($this->container['items']) < 1)) { + $invalidProperties[] = "invalid value for 'items', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\OrderBoxLayoutItemDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\OrderBoxLayoutItemDTO[] $items Список товаров в коробке. Если в коробке едет часть большого товара, в списке может быть только один пункт. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + + + if ((count($items) < 1)) { + throw new \InvalidArgumentException('invalid length for $items when calling OrderBoxLayoutDTO., number of items must be greater than or equal to 1.'); + } + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBoxLayoutItemDTO.php b/erp24/lib/yandex_market_api/Model/OrderBoxLayoutItemDTO.php new file mode 100644 index 00000000..0932ab65 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBoxLayoutItemDTO.php @@ -0,0 +1,531 @@ + + */ +class OrderBoxLayoutItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBoxLayoutItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'full_count' => 'int', + 'partial_count' => '\OpenAPI\Client\Model\OrderBoxLayoutPartialCountDTO', + 'instances' => '\OpenAPI\Client\Model\BriefOrderItemInstanceDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'full_count' => 'int32', + 'partial_count' => null, + 'instances' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'full_count' => false, + 'partial_count' => false, + 'instances' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'full_count' => 'fullCount', + 'partial_count' => 'partialCount', + 'instances' => 'instances' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'full_count' => 'setFullCount', + 'partial_count' => 'setPartialCount', + 'instances' => 'setInstances' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'full_count' => 'getFullCount', + 'partial_count' => 'getPartialCount', + 'instances' => 'getInstances' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('full_count', $data ?? [], null); + $this->setIfExists('partial_count', $data ?? [], null); + $this->setIfExists('instances', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if (!is_null($this->container['full_count']) && ($this->container['full_count'] < 1)) { + $invalidProperties[] = "invalid value for 'full_count', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор товара в заказе. {% cut \"Где его взять\" %} Идентификатор приходит в ответе на запрос [GET campaigns/{campaignId}/orders/{orderId}](../../reference/orders/getOrder.md) и в запросе Маркета [POST order/accept](../../pushapi/reference/orderAccept.md) — параметр `id` в `items`. {% endcut %}   + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets full_count + * + * @return int|null + */ + public function getFullCount() + { + return $this->container['full_count']; + } + + /** + * Sets full_count + * + * @param int|null $full_count Количество единиц товара в коробке. Используйте это поле, если в коробке поедут целые товары, не разделенные на части. Не используйте это поле одновременно с `partialCount`. + * + * @return self + */ + public function setFullCount($full_count) + { + if (is_null($full_count)) { + throw new \InvalidArgumentException('non-nullable full_count cannot be null'); + } + + if (($full_count < 1)) { + throw new \InvalidArgumentException('invalid value for $full_count when calling OrderBoxLayoutItemDTO., must be bigger than or equal to 1.'); + } + + $this->container['full_count'] = $full_count; + + return $this; + } + + /** + * Gets partial_count + * + * @return \OpenAPI\Client\Model\OrderBoxLayoutPartialCountDTO|null + */ + public function getPartialCount() + { + return $this->container['partial_count']; + } + + /** + * Sets partial_count + * + * @param \OpenAPI\Client\Model\OrderBoxLayoutPartialCountDTO|null $partial_count partial_count + * + * @return self + */ + public function setPartialCount($partial_count) + { + if (is_null($partial_count)) { + throw new \InvalidArgumentException('non-nullable partial_count cannot be null'); + } + $this->container['partial_count'] = $partial_count; + + return $this; + } + + /** + * Gets instances + * + * @return \OpenAPI\Client\Model\BriefOrderItemInstanceDTO[]|null + */ + public function getInstances() + { + return $this->container['instances']; + } + + /** + * Sets instances + * + * @param \OpenAPI\Client\Model\BriefOrderItemInstanceDTO[]|null $instances Переданные вами коды маркировки. + * + * @return self + */ + public function setInstances($instances) + { + if (is_null($instances)) { + array_push($this->openAPINullablesSetToNull, 'instances'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('instances', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['instances'] = $instances; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBoxLayoutPartialCountDTO.php b/erp24/lib/yandex_market_api/Model/OrderBoxLayoutPartialCountDTO.php new file mode 100644 index 00000000..fe78e212 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBoxLayoutPartialCountDTO.php @@ -0,0 +1,468 @@ + + */ +class OrderBoxLayoutPartialCountDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBoxLayoutPartialCountDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'current' => 'int', + 'total' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'current' => 'int32', + 'total' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'current' => false, + 'total' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'current' => 'current', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'current' => 'setCurrent', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'current' => 'getCurrent', + 'total' => 'getTotal' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('current', $data ?? [], null); + $this->setIfExists('total', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['current'] === null) { + $invalidProperties[] = "'current' can't be null"; + } + if (($this->container['current'] < 1)) { + $invalidProperties[] = "invalid value for 'current', must be bigger than or equal to 1."; + } + + if ($this->container['total'] === null) { + $invalidProperties[] = "'total' can't be null"; + } + if (($this->container['total'] < 2)) { + $invalidProperties[] = "invalid value for 'total', must be bigger than or equal to 2."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets current + * + * @return int + */ + public function getCurrent() + { + return $this->container['current']; + } + + /** + * Sets current + * + * @param int $current Номер части, начиная с 1. + * + * @return self + */ + public function setCurrent($current) + { + if (is_null($current)) { + throw new \InvalidArgumentException('non-nullable current cannot be null'); + } + + if (($current < 1)) { + throw new \InvalidArgumentException('invalid value for $current when calling OrderBoxLayoutPartialCountDTO., must be bigger than or equal to 1.'); + } + + $this->container['current'] = $current; + + return $this; + } + + /** + * Gets total + * + * @return int + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param int $total На сколько всего частей разделен товар. + * + * @return self + */ + public function setTotal($total) + { + if (is_null($total)) { + throw new \InvalidArgumentException('non-nullable total cannot be null'); + } + + if (($total < 2)) { + throw new \InvalidArgumentException('invalid value for $total when calling OrderBoxLayoutPartialCountDTO., must be bigger than or equal to 2.'); + } + + $this->container['total'] = $total; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBoxesLayoutDTO.php b/erp24/lib/yandex_market_api/Model/OrderBoxesLayoutDTO.php new file mode 100644 index 00000000..7e780935 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBoxesLayoutDTO.php @@ -0,0 +1,413 @@ + + */ +class OrderBoxesLayoutDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBoxesLayoutDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'boxes' => '\OpenAPI\Client\Model\EnrichedOrderBoxLayoutDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'boxes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'boxes' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'boxes' => 'boxes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'boxes' => 'setBoxes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'boxes' => 'getBoxes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('boxes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['boxes'] === null) { + $invalidProperties[] = "'boxes' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets boxes + * + * @return \OpenAPI\Client\Model\EnrichedOrderBoxLayoutDTO[] + */ + public function getBoxes() + { + return $this->container['boxes']; + } + + /** + * Sets boxes + * + * @param \OpenAPI\Client\Model\EnrichedOrderBoxLayoutDTO[] $boxes Список коробок. + * + * @return self + */ + public function setBoxes($boxes) + { + if (is_null($boxes)) { + throw new \InvalidArgumentException('non-nullable boxes cannot be null'); + } + $this->container['boxes'] = $boxes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBusinessBuyerDTO.php b/erp24/lib/yandex_market_api/Model/OrderBusinessBuyerDTO.php new file mode 100644 index 00000000..7edbc87e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBusinessBuyerDTO.php @@ -0,0 +1,512 @@ + + */ +class OrderBusinessBuyerDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBusinessBuyerDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'inn' => 'string', + 'kpp' => 'string', + 'organization_name' => 'string', + 'organization_jur_address' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'inn' => null, + 'kpp' => null, + 'organization_name' => null, + 'organization_jur_address' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'inn' => false, + 'kpp' => false, + 'organization_name' => false, + 'organization_jur_address' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'inn' => 'inn', + 'kpp' => 'kpp', + 'organization_name' => 'organizationName', + 'organization_jur_address' => 'organizationJurAddress' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'inn' => 'setInn', + 'kpp' => 'setKpp', + 'organization_name' => 'setOrganizationName', + 'organization_jur_address' => 'setOrganizationJurAddress' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'inn' => 'getInn', + 'kpp' => 'getKpp', + 'organization_name' => 'getOrganizationName', + 'organization_jur_address' => 'getOrganizationJurAddress' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('inn', $data ?? [], null); + $this->setIfExists('kpp', $data ?? [], null); + $this->setIfExists('organization_name', $data ?? [], null); + $this->setIfExists('organization_jur_address', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets inn + * + * @return string|null + */ + public function getInn() + { + return $this->container['inn']; + } + + /** + * Sets inn + * + * @param string|null $inn ИНН. + * + * @return self + */ + public function setInn($inn) + { + if (is_null($inn)) { + throw new \InvalidArgumentException('non-nullable inn cannot be null'); + } + $this->container['inn'] = $inn; + + return $this; + } + + /** + * Gets kpp + * + * @return string|null + */ + public function getKpp() + { + return $this->container['kpp']; + } + + /** + * Sets kpp + * + * @param string|null $kpp КПП. + * + * @return self + */ + public function setKpp($kpp) + { + if (is_null($kpp)) { + throw new \InvalidArgumentException('non-nullable kpp cannot be null'); + } + $this->container['kpp'] = $kpp; + + return $this; + } + + /** + * Gets organization_name + * + * @return string|null + */ + public function getOrganizationName() + { + return $this->container['organization_name']; + } + + /** + * Sets organization_name + * + * @param string|null $organization_name Наименование юридического лица. + * + * @return self + */ + public function setOrganizationName($organization_name) + { + if (is_null($organization_name)) { + throw new \InvalidArgumentException('non-nullable organization_name cannot be null'); + } + $this->container['organization_name'] = $organization_name; + + return $this; + } + + /** + * Gets organization_jur_address + * + * @return string|null + */ + public function getOrganizationJurAddress() + { + return $this->container['organization_jur_address']; + } + + /** + * Sets organization_jur_address + * + * @param string|null $organization_jur_address Юридический адрес. + * + * @return self + */ + public function setOrganizationJurAddress($organization_jur_address) + { + if (is_null($organization_jur_address)) { + throw new \InvalidArgumentException('non-nullable organization_jur_address cannot be null'); + } + $this->container['organization_jur_address'] = $organization_jur_address; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBusinessDocumentsDTO.php b/erp24/lib/yandex_market_api/Model/OrderBusinessDocumentsDTO.php new file mode 100644 index 00000000..b16e8ea6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBusinessDocumentsDTO.php @@ -0,0 +1,546 @@ + + */ +class OrderBusinessDocumentsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBusinessDocumentsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'upd' => '\OpenAPI\Client\Model\DocumentDTO', + 'ukd' => '\OpenAPI\Client\Model\DocumentDTO', + 'torg_twelve' => '\OpenAPI\Client\Model\DocumentDTO', + 'sf' => '\OpenAPI\Client\Model\DocumentDTO', + 'ksf' => '\OpenAPI\Client\Model\DocumentDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'upd' => null, + 'ukd' => null, + 'torg_twelve' => null, + 'sf' => null, + 'ksf' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'upd' => false, + 'ukd' => false, + 'torg_twelve' => false, + 'sf' => false, + 'ksf' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'upd' => 'upd', + 'ukd' => 'ukd', + 'torg_twelve' => 'torgTwelve', + 'sf' => 'sf', + 'ksf' => 'ksf' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'upd' => 'setUpd', + 'ukd' => 'setUkd', + 'torg_twelve' => 'setTorgTwelve', + 'sf' => 'setSf', + 'ksf' => 'setKsf' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'upd' => 'getUpd', + 'ukd' => 'getUkd', + 'torg_twelve' => 'getTorgTwelve', + 'sf' => 'getSf', + 'ksf' => 'getKsf' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('upd', $data ?? [], null); + $this->setIfExists('ukd', $data ?? [], null); + $this->setIfExists('torg_twelve', $data ?? [], null); + $this->setIfExists('sf', $data ?? [], null); + $this->setIfExists('ksf', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets upd + * + * @return \OpenAPI\Client\Model\DocumentDTO|null + */ + public function getUpd() + { + return $this->container['upd']; + } + + /** + * Sets upd + * + * @param \OpenAPI\Client\Model\DocumentDTO|null $upd upd + * + * @return self + */ + public function setUpd($upd) + { + if (is_null($upd)) { + throw new \InvalidArgumentException('non-nullable upd cannot be null'); + } + $this->container['upd'] = $upd; + + return $this; + } + + /** + * Gets ukd + * + * @return \OpenAPI\Client\Model\DocumentDTO|null + */ + public function getUkd() + { + return $this->container['ukd']; + } + + /** + * Sets ukd + * + * @param \OpenAPI\Client\Model\DocumentDTO|null $ukd ukd + * + * @return self + */ + public function setUkd($ukd) + { + if (is_null($ukd)) { + throw new \InvalidArgumentException('non-nullable ukd cannot be null'); + } + $this->container['ukd'] = $ukd; + + return $this; + } + + /** + * Gets torg_twelve + * + * @return \OpenAPI\Client\Model\DocumentDTO|null + */ + public function getTorgTwelve() + { + return $this->container['torg_twelve']; + } + + /** + * Sets torg_twelve + * + * @param \OpenAPI\Client\Model\DocumentDTO|null $torg_twelve torg_twelve + * + * @return self + */ + public function setTorgTwelve($torg_twelve) + { + if (is_null($torg_twelve)) { + throw new \InvalidArgumentException('non-nullable torg_twelve cannot be null'); + } + $this->container['torg_twelve'] = $torg_twelve; + + return $this; + } + + /** + * Gets sf + * + * @return \OpenAPI\Client\Model\DocumentDTO|null + */ + public function getSf() + { + return $this->container['sf']; + } + + /** + * Sets sf + * + * @param \OpenAPI\Client\Model\DocumentDTO|null $sf sf + * + * @return self + */ + public function setSf($sf) + { + if (is_null($sf)) { + throw new \InvalidArgumentException('non-nullable sf cannot be null'); + } + $this->container['sf'] = $sf; + + return $this; + } + + /** + * Gets ksf + * + * @return \OpenAPI\Client\Model\DocumentDTO|null + */ + public function getKsf() + { + return $this->container['ksf']; + } + + /** + * Sets ksf + * + * @param \OpenAPI\Client\Model\DocumentDTO|null $ksf ksf + * + * @return self + */ + public function setKsf($ksf) + { + if (is_null($ksf)) { + throw new \InvalidArgumentException('non-nullable ksf cannot be null'); + } + $this->container['ksf'] = $ksf; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBuyerBasicInfoDTO.php b/erp24/lib/yandex_market_api/Model/OrderBuyerBasicInfoDTO.php new file mode 100644 index 00000000..2c08ab36 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBuyerBasicInfoDTO.php @@ -0,0 +1,546 @@ + + */ +class OrderBuyerBasicInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBuyerBasicInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'last_name' => 'string', + 'first_name' => 'string', + 'middle_name' => 'string', + 'type' => '\OpenAPI\Client\Model\OrderBuyerType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'last_name' => null, + 'first_name' => null, + 'middle_name' => null, + 'type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'last_name' => false, + 'first_name' => false, + 'middle_name' => false, + 'type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'last_name' => 'lastName', + 'first_name' => 'firstName', + 'middle_name' => 'middleName', + 'type' => 'type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'last_name' => 'setLastName', + 'first_name' => 'setFirstName', + 'middle_name' => 'setMiddleName', + 'type' => 'setType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'last_name' => 'getLastName', + 'first_name' => 'getFirstName', + 'middle_name' => 'getMiddleName', + 'type' => 'getType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('last_name', $data ?? [], null); + $this->setIfExists('first_name', $data ?? [], null); + $this->setIfExists('middle_name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Идентификатор покупателя. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name Фамилия покупателя. + * + * @return self + */ + public function setLastName($last_name) + { + if (is_null($last_name)) { + throw new \InvalidArgumentException('non-nullable last_name cannot be null'); + } + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name Имя покупателя. + * + * @return self + */ + public function setFirstName($first_name) + { + if (is_null($first_name)) { + throw new \InvalidArgumentException('non-nullable first_name cannot be null'); + } + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets middle_name + * + * @return string|null + */ + public function getMiddleName() + { + return $this->container['middle_name']; + } + + /** + * Sets middle_name + * + * @param string|null $middle_name Отчество покупателя. + * + * @return self + */ + public function setMiddleName($middle_name) + { + if (is_null($middle_name)) { + throw new \InvalidArgumentException('non-nullable middle_name cannot be null'); + } + $this->container['middle_name'] = $middle_name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrderBuyerType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrderBuyerType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBuyerDTO.php b/erp24/lib/yandex_market_api/Model/OrderBuyerDTO.php new file mode 100644 index 00000000..63bb5b21 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBuyerDTO.php @@ -0,0 +1,546 @@ + + */ +class OrderBuyerDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBuyerDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'last_name' => 'string', + 'first_name' => 'string', + 'middle_name' => 'string', + 'type' => '\OpenAPI\Client\Model\OrderBuyerType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'last_name' => null, + 'first_name' => null, + 'middle_name' => null, + 'type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'last_name' => false, + 'first_name' => false, + 'middle_name' => false, + 'type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'last_name' => 'lastName', + 'first_name' => 'firstName', + 'middle_name' => 'middleName', + 'type' => 'type' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'last_name' => 'setLastName', + 'first_name' => 'setFirstName', + 'middle_name' => 'setMiddleName', + 'type' => 'setType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'last_name' => 'getLastName', + 'first_name' => 'getFirstName', + 'middle_name' => 'getMiddleName', + 'type' => 'getType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('last_name', $data ?? [], null); + $this->setIfExists('first_name', $data ?? [], null); + $this->setIfExists('middle_name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Идентификатор покупателя. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name Фамилия покупателя. + * + * @return self + */ + public function setLastName($last_name) + { + if (is_null($last_name)) { + throw new \InvalidArgumentException('non-nullable last_name cannot be null'); + } + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name Имя покупателя. + * + * @return self + */ + public function setFirstName($first_name) + { + if (is_null($first_name)) { + throw new \InvalidArgumentException('non-nullable first_name cannot be null'); + } + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets middle_name + * + * @return string|null + */ + public function getMiddleName() + { + return $this->container['middle_name']; + } + + /** + * Sets middle_name + * + * @param string|null $middle_name Отчество покупателя. + * + * @return self + */ + public function setMiddleName($middle_name) + { + if (is_null($middle_name)) { + throw new \InvalidArgumentException('non-nullable middle_name cannot be null'); + } + $this->container['middle_name'] = $middle_name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrderBuyerType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrderBuyerType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBuyerInfoDTO.php b/erp24/lib/yandex_market_api/Model/OrderBuyerInfoDTO.php new file mode 100644 index 00000000..b6e3a868 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBuyerInfoDTO.php @@ -0,0 +1,580 @@ + + */ +class OrderBuyerInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderBuyerInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'last_name' => 'string', + 'first_name' => 'string', + 'middle_name' => 'string', + 'type' => '\OpenAPI\Client\Model\OrderBuyerType', + 'phone' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'last_name' => null, + 'first_name' => null, + 'middle_name' => null, + 'type' => null, + 'phone' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'last_name' => false, + 'first_name' => false, + 'middle_name' => false, + 'type' => false, + 'phone' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'last_name' => 'lastName', + 'first_name' => 'firstName', + 'middle_name' => 'middleName', + 'type' => 'type', + 'phone' => 'phone' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'last_name' => 'setLastName', + 'first_name' => 'setFirstName', + 'middle_name' => 'setMiddleName', + 'type' => 'setType', + 'phone' => 'setPhone' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'last_name' => 'getLastName', + 'first_name' => 'getFirstName', + 'middle_name' => 'getMiddleName', + 'type' => 'getType', + 'phone' => 'getPhone' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('last_name', $data ?? [], null); + $this->setIfExists('first_name', $data ?? [], null); + $this->setIfExists('middle_name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('phone', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Идентификатор покупателя. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets last_name + * + * @return string|null + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string|null $last_name Фамилия покупателя. + * + * @return self + */ + public function setLastName($last_name) + { + if (is_null($last_name)) { + throw new \InvalidArgumentException('non-nullable last_name cannot be null'); + } + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets first_name + * + * @return string|null + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string|null $first_name Имя покупателя. + * + * @return self + */ + public function setFirstName($first_name) + { + if (is_null($first_name)) { + throw new \InvalidArgumentException('non-nullable first_name cannot be null'); + } + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets middle_name + * + * @return string|null + */ + public function getMiddleName() + { + return $this->container['middle_name']; + } + + /** + * Sets middle_name + * + * @param string|null $middle_name Отчество покупателя. + * + * @return self + */ + public function setMiddleName($middle_name) + { + if (is_null($middle_name)) { + throw new \InvalidArgumentException('non-nullable middle_name cannot be null'); + } + $this->container['middle_name'] = $middle_name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrderBuyerType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrderBuyerType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets phone + * + * @return string|null + */ + public function getPhone() + { + return $this->container['phone']; + } + + /** + * Sets phone + * + * @param string|null $phone Подменный номер телефона покупателя. Подробнее о таких номерах читайте [в Справке Маркета для продавцов](https://yandex.ru/support2/marketplace/ru/orders/dbs/call#fake-number). Формат номера: `+<код_страны><код_региона><номер_телефона>`. + * + * @return self + */ + public function setPhone($phone) + { + if (is_null($phone)) { + throw new \InvalidArgumentException('non-nullable phone cannot be null'); + } + $this->container['phone'] = $phone; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderBuyerType.php b/erp24/lib/yandex_market_api/Model/OrderBuyerType.php new file mode 100644 index 00000000..ee799094 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderBuyerType.php @@ -0,0 +1,63 @@ + + */ +class OrderCourierDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderCourierDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'full_name' => 'string', + 'phone' => 'string', + 'phone_extension' => 'string', + 'vehicle_number' => 'string', + 'vehicle_description' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'full_name' => null, + 'phone' => null, + 'phone_extension' => null, + 'vehicle_number' => null, + 'vehicle_description' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'full_name' => false, + 'phone' => false, + 'phone_extension' => false, + 'vehicle_number' => false, + 'vehicle_description' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'full_name' => 'fullName', + 'phone' => 'phone', + 'phone_extension' => 'phoneExtension', + 'vehicle_number' => 'vehicleNumber', + 'vehicle_description' => 'vehicleDescription' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'full_name' => 'setFullName', + 'phone' => 'setPhone', + 'phone_extension' => 'setPhoneExtension', + 'vehicle_number' => 'setVehicleNumber', + 'vehicle_description' => 'setVehicleDescription' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'full_name' => 'getFullName', + 'phone' => 'getPhone', + 'phone_extension' => 'getPhoneExtension', + 'vehicle_number' => 'getVehicleNumber', + 'vehicle_description' => 'getVehicleDescription' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('full_name', $data ?? [], null); + $this->setIfExists('phone', $data ?? [], null); + $this->setIfExists('phone_extension', $data ?? [], null); + $this->setIfExists('vehicle_number', $data ?? [], null); + $this->setIfExists('vehicle_description', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets full_name + * + * @return string|null + */ + public function getFullName() + { + return $this->container['full_name']; + } + + /** + * Sets full_name + * + * @param string|null $full_name Полное имя курьера. + * + * @return self + */ + public function setFullName($full_name) + { + if (is_null($full_name)) { + throw new \InvalidArgumentException('non-nullable full_name cannot be null'); + } + $this->container['full_name'] = $full_name; + + return $this; + } + + /** + * Gets phone + * + * @return string|null + */ + public function getPhone() + { + return $this->container['phone']; + } + + /** + * Sets phone + * + * @param string|null $phone Номер телефона курьера. + * + * @return self + */ + public function setPhone($phone) + { + if (is_null($phone)) { + throw new \InvalidArgumentException('non-nullable phone cannot be null'); + } + $this->container['phone'] = $phone; + + return $this; + } + + /** + * Gets phone_extension + * + * @return string|null + */ + public function getPhoneExtension() + { + return $this->container['phone_extension']; + } + + /** + * Sets phone_extension + * + * @param string|null $phone_extension Добавочный номер телефона. + * + * @return self + */ + public function setPhoneExtension($phone_extension) + { + if (is_null($phone_extension)) { + throw new \InvalidArgumentException('non-nullable phone_extension cannot be null'); + } + $this->container['phone_extension'] = $phone_extension; + + return $this; + } + + /** + * Gets vehicle_number + * + * @return string|null + */ + public function getVehicleNumber() + { + return $this->container['vehicle_number']; + } + + /** + * Sets vehicle_number + * + * @param string|null $vehicle_number Номер транспортного средства. + * + * @return self + */ + public function setVehicleNumber($vehicle_number) + { + if (is_null($vehicle_number)) { + throw new \InvalidArgumentException('non-nullable vehicle_number cannot be null'); + } + $this->container['vehicle_number'] = $vehicle_number; + + return $this; + } + + /** + * Gets vehicle_description + * + * @return string|null + */ + public function getVehicleDescription() + { + return $this->container['vehicle_description']; + } + + /** + * Sets vehicle_description + * + * @param string|null $vehicle_description Описание машины. Например, модель и цвет. + * + * @return self + */ + public function setVehicleDescription($vehicle_description) + { + if (is_null($vehicle_description)) { + throw new \InvalidArgumentException('non-nullable vehicle_description cannot be null'); + } + $this->container['vehicle_description'] = $vehicle_description; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderDTO.php b/erp24/lib/yandex_market_api/Model/OrderDTO.php new file mode 100644 index 00000000..408e6181 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderDTO.php @@ -0,0 +1,1174 @@ + + */ +class OrderDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'status' => '\OpenAPI\Client\Model\OrderStatusType', + 'substatus' => '\OpenAPI\Client\Model\OrderSubstatusType', + 'creation_date' => 'string', + 'updated_at' => 'string', + 'currency' => '\OpenAPI\Client\Model\CurrencyType', + 'items_total' => 'float', + 'delivery_total' => 'float', + 'buyer_items_total' => 'float', + 'buyer_total' => 'float', + 'buyer_items_total_before_discount' => 'float', + 'buyer_total_before_discount' => 'float', + 'payment_type' => '\OpenAPI\Client\Model\OrderPaymentType', + 'payment_method' => '\OpenAPI\Client\Model\OrderPaymentMethodType', + 'fake' => 'bool', + 'items' => '\OpenAPI\Client\Model\OrderItemDTO[]', + 'subsidies' => '\OpenAPI\Client\Model\OrderSubsidyDTO[]', + 'delivery' => '\OpenAPI\Client\Model\OrderDeliveryDTO', + 'buyer' => '\OpenAPI\Client\Model\OrderBuyerDTO', + 'notes' => 'string', + 'tax_system' => '\OpenAPI\Client\Model\OrderTaxSystemType', + 'cancel_requested' => 'bool', + 'expiry_date' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'status' => null, + 'substatus' => null, + 'creation_date' => 'date-dd-MM-yyyy-HH-mm-ss', + 'updated_at' => 'date-dd-MM-yyyy-HH-mm-ss', + 'currency' => null, + 'items_total' => 'decimal', + 'delivery_total' => 'decimal', + 'buyer_items_total' => 'decimal', + 'buyer_total' => 'decimal', + 'buyer_items_total_before_discount' => 'decimal', + 'buyer_total_before_discount' => 'decimal', + 'payment_type' => null, + 'payment_method' => null, + 'fake' => null, + 'items' => null, + 'subsidies' => null, + 'delivery' => null, + 'buyer' => null, + 'notes' => null, + 'tax_system' => null, + 'cancel_requested' => null, + 'expiry_date' => 'date-dd-MM-yyyy-HH-mm-ss' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'status' => false, + 'substatus' => false, + 'creation_date' => false, + 'updated_at' => false, + 'currency' => false, + 'items_total' => false, + 'delivery_total' => false, + 'buyer_items_total' => false, + 'buyer_total' => false, + 'buyer_items_total_before_discount' => false, + 'buyer_total_before_discount' => false, + 'payment_type' => false, + 'payment_method' => false, + 'fake' => false, + 'items' => false, + 'subsidies' => true, + 'delivery' => false, + 'buyer' => false, + 'notes' => false, + 'tax_system' => false, + 'cancel_requested' => false, + 'expiry_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'status' => 'status', + 'substatus' => 'substatus', + 'creation_date' => 'creationDate', + 'updated_at' => 'updatedAt', + 'currency' => 'currency', + 'items_total' => 'itemsTotal', + 'delivery_total' => 'deliveryTotal', + 'buyer_items_total' => 'buyerItemsTotal', + 'buyer_total' => 'buyerTotal', + 'buyer_items_total_before_discount' => 'buyerItemsTotalBeforeDiscount', + 'buyer_total_before_discount' => 'buyerTotalBeforeDiscount', + 'payment_type' => 'paymentType', + 'payment_method' => 'paymentMethod', + 'fake' => 'fake', + 'items' => 'items', + 'subsidies' => 'subsidies', + 'delivery' => 'delivery', + 'buyer' => 'buyer', + 'notes' => 'notes', + 'tax_system' => 'taxSystem', + 'cancel_requested' => 'cancelRequested', + 'expiry_date' => 'expiryDate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'status' => 'setStatus', + 'substatus' => 'setSubstatus', + 'creation_date' => 'setCreationDate', + 'updated_at' => 'setUpdatedAt', + 'currency' => 'setCurrency', + 'items_total' => 'setItemsTotal', + 'delivery_total' => 'setDeliveryTotal', + 'buyer_items_total' => 'setBuyerItemsTotal', + 'buyer_total' => 'setBuyerTotal', + 'buyer_items_total_before_discount' => 'setBuyerItemsTotalBeforeDiscount', + 'buyer_total_before_discount' => 'setBuyerTotalBeforeDiscount', + 'payment_type' => 'setPaymentType', + 'payment_method' => 'setPaymentMethod', + 'fake' => 'setFake', + 'items' => 'setItems', + 'subsidies' => 'setSubsidies', + 'delivery' => 'setDelivery', + 'buyer' => 'setBuyer', + 'notes' => 'setNotes', + 'tax_system' => 'setTaxSystem', + 'cancel_requested' => 'setCancelRequested', + 'expiry_date' => 'setExpiryDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'status' => 'getStatus', + 'substatus' => 'getSubstatus', + 'creation_date' => 'getCreationDate', + 'updated_at' => 'getUpdatedAt', + 'currency' => 'getCurrency', + 'items_total' => 'getItemsTotal', + 'delivery_total' => 'getDeliveryTotal', + 'buyer_items_total' => 'getBuyerItemsTotal', + 'buyer_total' => 'getBuyerTotal', + 'buyer_items_total_before_discount' => 'getBuyerItemsTotalBeforeDiscount', + 'buyer_total_before_discount' => 'getBuyerTotalBeforeDiscount', + 'payment_type' => 'getPaymentType', + 'payment_method' => 'getPaymentMethod', + 'fake' => 'getFake', + 'items' => 'getItems', + 'subsidies' => 'getSubsidies', + 'delivery' => 'getDelivery', + 'buyer' => 'getBuyer', + 'notes' => 'getNotes', + 'tax_system' => 'getTaxSystem', + 'cancel_requested' => 'getCancelRequested', + 'expiry_date' => 'getExpiryDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('substatus', $data ?? [], null); + $this->setIfExists('creation_date', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('items_total', $data ?? [], null); + $this->setIfExists('delivery_total', $data ?? [], null); + $this->setIfExists('buyer_items_total', $data ?? [], null); + $this->setIfExists('buyer_total', $data ?? [], null); + $this->setIfExists('buyer_items_total_before_discount', $data ?? [], null); + $this->setIfExists('buyer_total_before_discount', $data ?? [], null); + $this->setIfExists('payment_type', $data ?? [], null); + $this->setIfExists('payment_method', $data ?? [], null); + $this->setIfExists('fake', $data ?? [], null); + $this->setIfExists('items', $data ?? [], null); + $this->setIfExists('subsidies', $data ?? [], null); + $this->setIfExists('delivery', $data ?? [], null); + $this->setIfExists('buyer', $data ?? [], null); + $this->setIfExists('notes', $data ?? [], null); + $this->setIfExists('tax_system', $data ?? [], null); + $this->setIfExists('cancel_requested', $data ?? [], null); + $this->setIfExists('expiry_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор заказа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OrderStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OrderStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets substatus + * + * @return \OpenAPI\Client\Model\OrderSubstatusType|null + */ + public function getSubstatus() + { + return $this->container['substatus']; + } + + /** + * Sets substatus + * + * @param \OpenAPI\Client\Model\OrderSubstatusType|null $substatus substatus + * + * @return self + */ + public function setSubstatus($substatus) + { + if (is_null($substatus)) { + throw new \InvalidArgumentException('non-nullable substatus cannot be null'); + } + $this->container['substatus'] = $substatus; + + return $this; + } + + /** + * Gets creation_date + * + * @return string|null + */ + public function getCreationDate() + { + return $this->container['creation_date']; + } + + /** + * Sets creation_date + * + * @param string|null $creation_date creation_date + * + * @return self + */ + public function setCreationDate($creation_date) + { + if (is_null($creation_date)) { + throw new \InvalidArgumentException('non-nullable creation_date cannot be null'); + } + $this->container['creation_date'] = $creation_date; + + return $this; + } + + /** + * Gets updated_at + * + * @return string|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param string|null $updated_at updated_at + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + + /** + * Gets currency + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets items_total + * + * @return float|null + */ + public function getItemsTotal() + { + return $this->container['items_total']; + } + + /** + * Sets items_total + * + * @param float|null $items_total Платеж покупателя. + * + * @return self + */ + public function setItemsTotal($items_total) + { + if (is_null($items_total)) { + throw new \InvalidArgumentException('non-nullable items_total cannot be null'); + } + $this->container['items_total'] = $items_total; + + return $this; + } + + /** + * Gets delivery_total + * + * @return float|null + */ + public function getDeliveryTotal() + { + return $this->container['delivery_total']; + } + + /** + * Sets delivery_total + * + * @param float|null $delivery_total Стоимость доставки. + * + * @return self + */ + public function setDeliveryTotal($delivery_total) + { + if (is_null($delivery_total)) { + throw new \InvalidArgumentException('non-nullable delivery_total cannot be null'); + } + $this->container['delivery_total'] = $delivery_total; + + return $this; + } + + /** + * Gets buyer_items_total + * + * @return float|null + * @deprecated + */ + public function getBuyerItemsTotal() + { + return $this->container['buyer_items_total']; + } + + /** + * Sets buyer_items_total + * + * @param float|null $buyer_items_total {% note warning \"\" %} Этот параметр устарел. {% endnote %} Стоимость всех товаров в заказе в валюте покупателя после применения скидок и без учета стоимости доставки. + * + * @return self + * @deprecated + */ + public function setBuyerItemsTotal($buyer_items_total) + { + if (is_null($buyer_items_total)) { + throw new \InvalidArgumentException('non-nullable buyer_items_total cannot be null'); + } + $this->container['buyer_items_total'] = $buyer_items_total; + + return $this; + } + + /** + * Gets buyer_total + * + * @return float|null + * @deprecated + */ + public function getBuyerTotal() + { + return $this->container['buyer_total']; + } + + /** + * Sets buyer_total + * + * @param float|null $buyer_total {% note warning \"\" %} Этот параметр устарел. {% endnote %} Стоимость всех товаров в заказе в валюте покупателя после применения скидок и с учетом стоимости доставки. + * + * @return self + * @deprecated + */ + public function setBuyerTotal($buyer_total) + { + if (is_null($buyer_total)) { + throw new \InvalidArgumentException('non-nullable buyer_total cannot be null'); + } + $this->container['buyer_total'] = $buyer_total; + + return $this; + } + + /** + * Gets buyer_items_total_before_discount + * + * @return float|null + */ + public function getBuyerItemsTotalBeforeDiscount() + { + return $this->container['buyer_items_total_before_discount']; + } + + /** + * Sets buyer_items_total_before_discount + * + * @param float|null $buyer_items_total_before_discount Стоимость всех товаров в заказе в валюте покупателя без учета стоимости доставки и до применения скидок по: * акциям; * купонам; * промокодам. + * + * @return self + */ + public function setBuyerItemsTotalBeforeDiscount($buyer_items_total_before_discount) + { + if (is_null($buyer_items_total_before_discount)) { + throw new \InvalidArgumentException('non-nullable buyer_items_total_before_discount cannot be null'); + } + $this->container['buyer_items_total_before_discount'] = $buyer_items_total_before_discount; + + return $this; + } + + /** + * Gets buyer_total_before_discount + * + * @return float|null + * @deprecated + */ + public function getBuyerTotalBeforeDiscount() + { + return $this->container['buyer_total_before_discount']; + } + + /** + * Sets buyer_total_before_discount + * + * @param float|null $buyer_total_before_discount {% note warning \"\" %} Этот параметр устарел. {% endnote %} Стоимость всех товаров в заказе в валюте покупателя до применения скидок и с учетом стоимости доставки (`buyerItemsTotalBeforeDiscount` + стоимость доставки). + * + * @return self + * @deprecated + */ + public function setBuyerTotalBeforeDiscount($buyer_total_before_discount) + { + if (is_null($buyer_total_before_discount)) { + throw new \InvalidArgumentException('non-nullable buyer_total_before_discount cannot be null'); + } + $this->container['buyer_total_before_discount'] = $buyer_total_before_discount; + + return $this; + } + + /** + * Gets payment_type + * + * @return \OpenAPI\Client\Model\OrderPaymentType|null + */ + public function getPaymentType() + { + return $this->container['payment_type']; + } + + /** + * Sets payment_type + * + * @param \OpenAPI\Client\Model\OrderPaymentType|null $payment_type payment_type + * + * @return self + */ + public function setPaymentType($payment_type) + { + if (is_null($payment_type)) { + throw new \InvalidArgumentException('non-nullable payment_type cannot be null'); + } + $this->container['payment_type'] = $payment_type; + + return $this; + } + + /** + * Gets payment_method + * + * @return \OpenAPI\Client\Model\OrderPaymentMethodType|null + */ + public function getPaymentMethod() + { + return $this->container['payment_method']; + } + + /** + * Sets payment_method + * + * @param \OpenAPI\Client\Model\OrderPaymentMethodType|null $payment_method payment_method + * + * @return self + */ + public function setPaymentMethod($payment_method) + { + if (is_null($payment_method)) { + throw new \InvalidArgumentException('non-nullable payment_method cannot be null'); + } + $this->container['payment_method'] = $payment_method; + + return $this; + } + + /** + * Gets fake + * + * @return bool|null + */ + public function getFake() + { + return $this->container['fake']; + } + + /** + * Sets fake + * + * @param bool|null $fake Тип заказа: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. + * + * @return self + */ + public function setFake($fake) + { + if (is_null($fake)) { + throw new \InvalidArgumentException('non-nullable fake cannot be null'); + } + $this->container['fake'] = $fake; + + return $this; + } + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\OrderItemDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\OrderItemDTO[] $items Список товаров в заказе. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets subsidies + * + * @return \OpenAPI\Client\Model\OrderSubsidyDTO[]|null + */ + public function getSubsidies() + { + return $this->container['subsidies']; + } + + /** + * Sets subsidies + * + * @param \OpenAPI\Client\Model\OrderSubsidyDTO[]|null $subsidies Список субсидий по типам. + * + * @return self + */ + public function setSubsidies($subsidies) + { + if (is_null($subsidies)) { + array_push($this->openAPINullablesSetToNull, 'subsidies'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('subsidies', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['subsidies'] = $subsidies; + + return $this; + } + + /** + * Gets delivery + * + * @return \OpenAPI\Client\Model\OrderDeliveryDTO|null + */ + public function getDelivery() + { + return $this->container['delivery']; + } + + /** + * Sets delivery + * + * @param \OpenAPI\Client\Model\OrderDeliveryDTO|null $delivery delivery + * + * @return self + */ + public function setDelivery($delivery) + { + if (is_null($delivery)) { + throw new \InvalidArgumentException('non-nullable delivery cannot be null'); + } + $this->container['delivery'] = $delivery; + + return $this; + } + + /** + * Gets buyer + * + * @return \OpenAPI\Client\Model\OrderBuyerDTO|null + */ + public function getBuyer() + { + return $this->container['buyer']; + } + + /** + * Sets buyer + * + * @param \OpenAPI\Client\Model\OrderBuyerDTO|null $buyer buyer + * + * @return self + */ + public function setBuyer($buyer) + { + if (is_null($buyer)) { + throw new \InvalidArgumentException('non-nullable buyer cannot be null'); + } + $this->container['buyer'] = $buyer; + + return $this; + } + + /** + * Gets notes + * + * @return string|null + */ + public function getNotes() + { + return $this->container['notes']; + } + + /** + * Sets notes + * + * @param string|null $notes Комментарий к заказу. + * + * @return self + */ + public function setNotes($notes) + { + if (is_null($notes)) { + throw new \InvalidArgumentException('non-nullable notes cannot be null'); + } + $this->container['notes'] = $notes; + + return $this; + } + + /** + * Gets tax_system + * + * @return \OpenAPI\Client\Model\OrderTaxSystemType|null + */ + public function getTaxSystem() + { + return $this->container['tax_system']; + } + + /** + * Sets tax_system + * + * @param \OpenAPI\Client\Model\OrderTaxSystemType|null $tax_system tax_system + * + * @return self + */ + public function setTaxSystem($tax_system) + { + if (is_null($tax_system)) { + throw new \InvalidArgumentException('non-nullable tax_system cannot be null'); + } + $this->container['tax_system'] = $tax_system; + + return $this; + } + + /** + * Gets cancel_requested + * + * @return bool|null + */ + public function getCancelRequested() + { + return $this->container['cancel_requested']; + } + + /** + * Sets cancel_requested + * + * @param bool|null $cancel_requested **Только для модели DBS** Запрошена ли отмена. + * + * @return self + */ + public function setCancelRequested($cancel_requested) + { + if (is_null($cancel_requested)) { + throw new \InvalidArgumentException('non-nullable cancel_requested cannot be null'); + } + $this->container['cancel_requested'] = $cancel_requested; + + return $this; + } + + /** + * Gets expiry_date + * + * @return string|null + */ + public function getExpiryDate() + { + return $this->container['expiry_date']; + } + + /** + * Sets expiry_date + * + * @param string|null $expiry_date expiry_date + * + * @return self + */ + public function setExpiryDate($expiry_date) + { + if (is_null($expiry_date)) { + throw new \InvalidArgumentException('non-nullable expiry_date cannot be null'); + } + $this->container['expiry_date'] = $expiry_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderDeliveryAddressDTO.php b/erp24/lib/yandex_market_api/Model/OrderDeliveryAddressDTO.php new file mode 100644 index 00000000..32f55f87 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderDeliveryAddressDTO.php @@ -0,0 +1,886 @@ + + */ +class OrderDeliveryAddressDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderDeliveryAddressDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'country' => 'string', + 'postcode' => 'string', + 'city' => 'string', + 'district' => 'string', + 'subway' => 'string', + 'street' => 'string', + 'house' => 'string', + 'block' => 'string', + 'entrance' => 'string', + 'entryphone' => 'string', + 'floor' => 'string', + 'apartment' => 'string', + 'phone' => 'string', + 'recipient' => 'string', + 'gps' => '\OpenAPI\Client\Model\GpsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'country' => null, + 'postcode' => null, + 'city' => null, + 'district' => null, + 'subway' => null, + 'street' => null, + 'house' => null, + 'block' => null, + 'entrance' => null, + 'entryphone' => null, + 'floor' => null, + 'apartment' => null, + 'phone' => null, + 'recipient' => null, + 'gps' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'country' => false, + 'postcode' => false, + 'city' => false, + 'district' => false, + 'subway' => false, + 'street' => false, + 'house' => false, + 'block' => false, + 'entrance' => false, + 'entryphone' => false, + 'floor' => false, + 'apartment' => false, + 'phone' => false, + 'recipient' => false, + 'gps' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'country' => 'country', + 'postcode' => 'postcode', + 'city' => 'city', + 'district' => 'district', + 'subway' => 'subway', + 'street' => 'street', + 'house' => 'house', + 'block' => 'block', + 'entrance' => 'entrance', + 'entryphone' => 'entryphone', + 'floor' => 'floor', + 'apartment' => 'apartment', + 'phone' => 'phone', + 'recipient' => 'recipient', + 'gps' => 'gps' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'country' => 'setCountry', + 'postcode' => 'setPostcode', + 'city' => 'setCity', + 'district' => 'setDistrict', + 'subway' => 'setSubway', + 'street' => 'setStreet', + 'house' => 'setHouse', + 'block' => 'setBlock', + 'entrance' => 'setEntrance', + 'entryphone' => 'setEntryphone', + 'floor' => 'setFloor', + 'apartment' => 'setApartment', + 'phone' => 'setPhone', + 'recipient' => 'setRecipient', + 'gps' => 'setGps' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'country' => 'getCountry', + 'postcode' => 'getPostcode', + 'city' => 'getCity', + 'district' => 'getDistrict', + 'subway' => 'getSubway', + 'street' => 'getStreet', + 'house' => 'getHouse', + 'block' => 'getBlock', + 'entrance' => 'getEntrance', + 'entryphone' => 'getEntryphone', + 'floor' => 'getFloor', + 'apartment' => 'getApartment', + 'phone' => 'getPhone', + 'recipient' => 'getRecipient', + 'gps' => 'getGps' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('country', $data ?? [], null); + $this->setIfExists('postcode', $data ?? [], null); + $this->setIfExists('city', $data ?? [], null); + $this->setIfExists('district', $data ?? [], null); + $this->setIfExists('subway', $data ?? [], null); + $this->setIfExists('street', $data ?? [], null); + $this->setIfExists('house', $data ?? [], null); + $this->setIfExists('block', $data ?? [], null); + $this->setIfExists('entrance', $data ?? [], null); + $this->setIfExists('entryphone', $data ?? [], null); + $this->setIfExists('floor', $data ?? [], null); + $this->setIfExists('apartment', $data ?? [], null); + $this->setIfExists('phone', $data ?? [], null); + $this->setIfExists('recipient', $data ?? [], null); + $this->setIfExists('gps', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country Страна. Обязательный параметр. + * + * @return self + */ + public function setCountry($country) + { + if (is_null($country)) { + throw new \InvalidArgumentException('non-nullable country cannot be null'); + } + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets postcode + * + * @return string|null + */ + public function getPostcode() + { + return $this->container['postcode']; + } + + /** + * Sets postcode + * + * @param string|null $postcode Почтовый индекс. Указывается, если выбрана доставка почтой (`delivery type=POST`). + * + * @return self + */ + public function setPostcode($postcode) + { + if (is_null($postcode)) { + throw new \InvalidArgumentException('non-nullable postcode cannot be null'); + } + $this->container['postcode'] = $postcode; + + return $this; + } + + /** + * Gets city + * + * @return string|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string|null $city Город или населенный пункт. Обязательный параметр. + * + * @return self + */ + public function setCity($city) + { + if (is_null($city)) { + throw new \InvalidArgumentException('non-nullable city cannot be null'); + } + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets district + * + * @return string|null + */ + public function getDistrict() + { + return $this->container['district']; + } + + /** + * Sets district + * + * @param string|null $district Район. + * + * @return self + */ + public function setDistrict($district) + { + if (is_null($district)) { + throw new \InvalidArgumentException('non-nullable district cannot be null'); + } + $this->container['district'] = $district; + + return $this; + } + + /** + * Gets subway + * + * @return string|null + */ + public function getSubway() + { + return $this->container['subway']; + } + + /** + * Sets subway + * + * @param string|null $subway Станция метро. + * + * @return self + */ + public function setSubway($subway) + { + if (is_null($subway)) { + throw new \InvalidArgumentException('non-nullable subway cannot be null'); + } + $this->container['subway'] = $subway; + + return $this; + } + + /** + * Gets street + * + * @return string|null + */ + public function getStreet() + { + return $this->container['street']; + } + + /** + * Sets street + * + * @param string|null $street Улица. Обязательный параметр. + * + * @return self + */ + public function setStreet($street) + { + if (is_null($street)) { + throw new \InvalidArgumentException('non-nullable street cannot be null'); + } + $this->container['street'] = $street; + + return $this; + } + + /** + * Gets house + * + * @return string|null + */ + public function getHouse() + { + return $this->container['house']; + } + + /** + * Sets house + * + * @param string|null $house Дом или владение. Обязательный параметр. + * + * @return self + */ + public function setHouse($house) + { + if (is_null($house)) { + throw new \InvalidArgumentException('non-nullable house cannot be null'); + } + $this->container['house'] = $house; + + return $this; + } + + /** + * Gets block + * + * @return string|null + */ + public function getBlock() + { + return $this->container['block']; + } + + /** + * Sets block + * + * @param string|null $block Корпус или строение. + * + * @return self + */ + public function setBlock($block) + { + if (is_null($block)) { + throw new \InvalidArgumentException('non-nullable block cannot be null'); + } + $this->container['block'] = $block; + + return $this; + } + + /** + * Gets entrance + * + * @return string|null + */ + public function getEntrance() + { + return $this->container['entrance']; + } + + /** + * Sets entrance + * + * @param string|null $entrance Подъезд. + * + * @return self + */ + public function setEntrance($entrance) + { + if (is_null($entrance)) { + throw new \InvalidArgumentException('non-nullable entrance cannot be null'); + } + $this->container['entrance'] = $entrance; + + return $this; + } + + /** + * Gets entryphone + * + * @return string|null + */ + public function getEntryphone() + { + return $this->container['entryphone']; + } + + /** + * Sets entryphone + * + * @param string|null $entryphone Код домофона. + * + * @return self + */ + public function setEntryphone($entryphone) + { + if (is_null($entryphone)) { + throw new \InvalidArgumentException('non-nullable entryphone cannot be null'); + } + $this->container['entryphone'] = $entryphone; + + return $this; + } + + /** + * Gets floor + * + * @return string|null + */ + public function getFloor() + { + return $this->container['floor']; + } + + /** + * Sets floor + * + * @param string|null $floor Этаж. + * + * @return self + */ + public function setFloor($floor) + { + if (is_null($floor)) { + throw new \InvalidArgumentException('non-nullable floor cannot be null'); + } + $this->container['floor'] = $floor; + + return $this; + } + + /** + * Gets apartment + * + * @return string|null + */ + public function getApartment() + { + return $this->container['apartment']; + } + + /** + * Sets apartment + * + * @param string|null $apartment Квартира или офис. + * + * @return self + */ + public function setApartment($apartment) + { + if (is_null($apartment)) { + throw new \InvalidArgumentException('non-nullable apartment cannot be null'); + } + $this->container['apartment'] = $apartment; + + return $this; + } + + /** + * Gets phone + * + * @return string|null + */ + public function getPhone() + { + return $this->container['phone']; + } + + /** + * Sets phone + * + * @param string|null $phone Телефон получателя заказа. Обязательный параметр. + * + * @return self + */ + public function setPhone($phone) + { + if (is_null($phone)) { + throw new \InvalidArgumentException('non-nullable phone cannot be null'); + } + $this->container['phone'] = $phone; + + return $this; + } + + /** + * Gets recipient + * + * @return string|null + */ + public function getRecipient() + { + return $this->container['recipient']; + } + + /** + * Sets recipient + * + * @param string|null $recipient Фамилия, имя и отчество получателя заказа. Обязательный параметр. + * + * @return self + */ + public function setRecipient($recipient) + { + if (is_null($recipient)) { + throw new \InvalidArgumentException('non-nullable recipient cannot be null'); + } + $this->container['recipient'] = $recipient; + + return $this; + } + + /** + * Gets gps + * + * @return \OpenAPI\Client\Model\GpsDTO|null + */ + public function getGps() + { + return $this->container['gps']; + } + + /** + * Sets gps + * + * @param \OpenAPI\Client\Model\GpsDTO|null $gps gps + * + * @return self + */ + public function setGps($gps) + { + if (is_null($gps)) { + throw new \InvalidArgumentException('non-nullable gps cannot be null'); + } + $this->container['gps'] = $gps; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderDeliveryDTO.php b/erp24/lib/yandex_market_api/Model/OrderDeliveryDTO.php new file mode 100644 index 00000000..0c961cc7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderDeliveryDTO.php @@ -0,0 +1,1106 @@ + + */ +class OrderDeliveryDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderDeliveryDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'type' => '\OpenAPI\Client\Model\OrderDeliveryType', + 'service_name' => 'string', + 'price' => 'float', + 'delivery_partner_type' => '\OpenAPI\Client\Model\OrderDeliveryPartnerType', + 'courier' => '\OpenAPI\Client\Model\OrderCourierDTO', + 'dates' => '\OpenAPI\Client\Model\OrderDeliveryDatesDTO', + 'region' => '\OpenAPI\Client\Model\RegionDTO', + 'address' => '\OpenAPI\Client\Model\OrderDeliveryAddressDTO', + 'vat' => '\OpenAPI\Client\Model\OrderVatType', + 'delivery_service_id' => 'int', + 'lift_type' => '\OpenAPI\Client\Model\OrderLiftType', + 'lift_price' => 'float', + 'outlet_code' => 'string', + 'outlet_storage_limit_date' => 'string', + 'dispatch_type' => '\OpenAPI\Client\Model\OrderDeliveryDispatchType', + 'tracks' => '\OpenAPI\Client\Model\OrderTrackDTO[]', + 'shipments' => '\OpenAPI\Client\Model\OrderShipmentDTO[]', + 'estimated' => 'bool', + 'eac_type' => '\OpenAPI\Client\Model\OrderDeliveryEacType', + 'eac_code' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'type' => null, + 'service_name' => null, + 'price' => 'decimal', + 'delivery_partner_type' => null, + 'courier' => null, + 'dates' => null, + 'region' => null, + 'address' => null, + 'vat' => null, + 'delivery_service_id' => 'int64', + 'lift_type' => null, + 'lift_price' => 'decimal', + 'outlet_code' => null, + 'outlet_storage_limit_date' => 'date-dd-MM-yyyy', + 'dispatch_type' => null, + 'tracks' => null, + 'shipments' => null, + 'estimated' => null, + 'eac_type' => null, + 'eac_code' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'type' => false, + 'service_name' => false, + 'price' => false, + 'delivery_partner_type' => false, + 'courier' => false, + 'dates' => false, + 'region' => false, + 'address' => false, + 'vat' => false, + 'delivery_service_id' => false, + 'lift_type' => false, + 'lift_price' => false, + 'outlet_code' => false, + 'outlet_storage_limit_date' => false, + 'dispatch_type' => false, + 'tracks' => true, + 'shipments' => true, + 'estimated' => false, + 'eac_type' => false, + 'eac_code' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'type' => 'type', + 'service_name' => 'serviceName', + 'price' => 'price', + 'delivery_partner_type' => 'deliveryPartnerType', + 'courier' => 'courier', + 'dates' => 'dates', + 'region' => 'region', + 'address' => 'address', + 'vat' => 'vat', + 'delivery_service_id' => 'deliveryServiceId', + 'lift_type' => 'liftType', + 'lift_price' => 'liftPrice', + 'outlet_code' => 'outletCode', + 'outlet_storage_limit_date' => 'outletStorageLimitDate', + 'dispatch_type' => 'dispatchType', + 'tracks' => 'tracks', + 'shipments' => 'shipments', + 'estimated' => 'estimated', + 'eac_type' => 'eacType', + 'eac_code' => 'eacCode' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'type' => 'setType', + 'service_name' => 'setServiceName', + 'price' => 'setPrice', + 'delivery_partner_type' => 'setDeliveryPartnerType', + 'courier' => 'setCourier', + 'dates' => 'setDates', + 'region' => 'setRegion', + 'address' => 'setAddress', + 'vat' => 'setVat', + 'delivery_service_id' => 'setDeliveryServiceId', + 'lift_type' => 'setLiftType', + 'lift_price' => 'setLiftPrice', + 'outlet_code' => 'setOutletCode', + 'outlet_storage_limit_date' => 'setOutletStorageLimitDate', + 'dispatch_type' => 'setDispatchType', + 'tracks' => 'setTracks', + 'shipments' => 'setShipments', + 'estimated' => 'setEstimated', + 'eac_type' => 'setEacType', + 'eac_code' => 'setEacCode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'type' => 'getType', + 'service_name' => 'getServiceName', + 'price' => 'getPrice', + 'delivery_partner_type' => 'getDeliveryPartnerType', + 'courier' => 'getCourier', + 'dates' => 'getDates', + 'region' => 'getRegion', + 'address' => 'getAddress', + 'vat' => 'getVat', + 'delivery_service_id' => 'getDeliveryServiceId', + 'lift_type' => 'getLiftType', + 'lift_price' => 'getLiftPrice', + 'outlet_code' => 'getOutletCode', + 'outlet_storage_limit_date' => 'getOutletStorageLimitDate', + 'dispatch_type' => 'getDispatchType', + 'tracks' => 'getTracks', + 'shipments' => 'getShipments', + 'estimated' => 'getEstimated', + 'eac_type' => 'getEacType', + 'eac_code' => 'getEacCode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('service_name', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('delivery_partner_type', $data ?? [], null); + $this->setIfExists('courier', $data ?? [], null); + $this->setIfExists('dates', $data ?? [], null); + $this->setIfExists('region', $data ?? [], null); + $this->setIfExists('address', $data ?? [], null); + $this->setIfExists('vat', $data ?? [], null); + $this->setIfExists('delivery_service_id', $data ?? [], null); + $this->setIfExists('lift_type', $data ?? [], null); + $this->setIfExists('lift_price', $data ?? [], null); + $this->setIfExists('outlet_code', $data ?? [], null); + $this->setIfExists('outlet_storage_limit_date', $data ?? [], null); + $this->setIfExists('dispatch_type', $data ?? [], null); + $this->setIfExists('tracks', $data ?? [], null); + $this->setIfExists('shipments', $data ?? [], null); + $this->setIfExists('estimated', $data ?? [], null); + $this->setIfExists('eac_type', $data ?? [], null); + $this->setIfExists('eac_code', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Идентификатор доставки, присвоенный магазином. Указывается, только если магазин передал данный идентификатор в ответе на запрос методом [POST cart](../../pushapi/reference/cart.md). + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrderDeliveryType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrderDeliveryType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets service_name + * + * @return string|null + */ + public function getServiceName() + { + return $this->container['service_name']; + } + + /** + * Sets service_name + * + * @param string|null $service_name Наименование службы доставки. + * + * @return self + */ + public function setServiceName($service_name) + { + if (is_null($service_name)) { + throw new \InvalidArgumentException('non-nullable service_name cannot be null'); + } + $this->container['service_name'] = $service_name; + + return $this; + } + + /** + * Gets price + * + * @return float|null + * @deprecated + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price {% note warning \"\" %} Этот параметр устарел. Стоимость доставки смотрите в параметре `deliveryTotal`. {% endnote %} Стоимость доставки в валюте заказа. + * + * @return self + * @deprecated + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets delivery_partner_type + * + * @return \OpenAPI\Client\Model\OrderDeliveryPartnerType|null + */ + public function getDeliveryPartnerType() + { + return $this->container['delivery_partner_type']; + } + + /** + * Sets delivery_partner_type + * + * @param \OpenAPI\Client\Model\OrderDeliveryPartnerType|null $delivery_partner_type delivery_partner_type + * + * @return self + */ + public function setDeliveryPartnerType($delivery_partner_type) + { + if (is_null($delivery_partner_type)) { + throw new \InvalidArgumentException('non-nullable delivery_partner_type cannot be null'); + } + $this->container['delivery_partner_type'] = $delivery_partner_type; + + return $this; + } + + /** + * Gets courier + * + * @return \OpenAPI\Client\Model\OrderCourierDTO|null + */ + public function getCourier() + { + return $this->container['courier']; + } + + /** + * Sets courier + * + * @param \OpenAPI\Client\Model\OrderCourierDTO|null $courier courier + * + * @return self + */ + public function setCourier($courier) + { + if (is_null($courier)) { + throw new \InvalidArgumentException('non-nullable courier cannot be null'); + } + $this->container['courier'] = $courier; + + return $this; + } + + /** + * Gets dates + * + * @return \OpenAPI\Client\Model\OrderDeliveryDatesDTO|null + */ + public function getDates() + { + return $this->container['dates']; + } + + /** + * Sets dates + * + * @param \OpenAPI\Client\Model\OrderDeliveryDatesDTO|null $dates dates + * + * @return self + */ + public function setDates($dates) + { + if (is_null($dates)) { + throw new \InvalidArgumentException('non-nullable dates cannot be null'); + } + $this->container['dates'] = $dates; + + return $this; + } + + /** + * Gets region + * + * @return \OpenAPI\Client\Model\RegionDTO|null + */ + public function getRegion() + { + return $this->container['region']; + } + + /** + * Sets region + * + * @param \OpenAPI\Client\Model\RegionDTO|null $region region + * + * @return self + */ + public function setRegion($region) + { + if (is_null($region)) { + throw new \InvalidArgumentException('non-nullable region cannot be null'); + } + $this->container['region'] = $region; + + return $this; + } + + /** + * Gets address + * + * @return \OpenAPI\Client\Model\OrderDeliveryAddressDTO|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \OpenAPI\Client\Model\OrderDeliveryAddressDTO|null $address address + * + * @return self + */ + public function setAddress($address) + { + if (is_null($address)) { + throw new \InvalidArgumentException('non-nullable address cannot be null'); + } + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets vat + * + * @return \OpenAPI\Client\Model\OrderVatType|null + */ + public function getVat() + { + return $this->container['vat']; + } + + /** + * Sets vat + * + * @param \OpenAPI\Client\Model\OrderVatType|null $vat vat + * + * @return self + */ + public function setVat($vat) + { + if (is_null($vat)) { + throw new \InvalidArgumentException('non-nullable vat cannot be null'); + } + $this->container['vat'] = $vat; + + return $this; + } + + /** + * Gets delivery_service_id + * + * @return int|null + */ + public function getDeliveryServiceId() + { + return $this->container['delivery_service_id']; + } + + /** + * Sets delivery_service_id + * + * @param int|null $delivery_service_id Идентификатор службы доставки. + * + * @return self + */ + public function setDeliveryServiceId($delivery_service_id) + { + if (is_null($delivery_service_id)) { + throw new \InvalidArgumentException('non-nullable delivery_service_id cannot be null'); + } + $this->container['delivery_service_id'] = $delivery_service_id; + + return $this; + } + + /** + * Gets lift_type + * + * @return \OpenAPI\Client\Model\OrderLiftType|null + */ + public function getLiftType() + { + return $this->container['lift_type']; + } + + /** + * Sets lift_type + * + * @param \OpenAPI\Client\Model\OrderLiftType|null $lift_type lift_type + * + * @return self + */ + public function setLiftType($lift_type) + { + if (is_null($lift_type)) { + throw new \InvalidArgumentException('non-nullable lift_type cannot be null'); + } + $this->container['lift_type'] = $lift_type; + + return $this; + } + + /** + * Gets lift_price + * + * @return float|null + */ + public function getLiftPrice() + { + return $this->container['lift_price']; + } + + /** + * Sets lift_price + * + * @param float|null $lift_price Стоимость подъема на этаж. + * + * @return self + */ + public function setLiftPrice($lift_price) + { + if (is_null($lift_price)) { + throw new \InvalidArgumentException('non-nullable lift_price cannot be null'); + } + $this->container['lift_price'] = $lift_price; + + return $this; + } + + /** + * Gets outlet_code + * + * @return string|null + */ + public function getOutletCode() + { + return $this->container['outlet_code']; + } + + /** + * Sets outlet_code + * + * @param string|null $outlet_code Идентификатор пункта самовывоза, присвоенный магазином. + * + * @return self + */ + public function setOutletCode($outlet_code) + { + if (is_null($outlet_code)) { + throw new \InvalidArgumentException('non-nullable outlet_code cannot be null'); + } + $this->container['outlet_code'] = $outlet_code; + + return $this; + } + + /** + * Gets outlet_storage_limit_date + * + * @return string|null + */ + public function getOutletStorageLimitDate() + { + return $this->container['outlet_storage_limit_date']; + } + + /** + * Sets outlet_storage_limit_date + * + * @param string|null $outlet_storage_limit_date Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setOutletStorageLimitDate($outlet_storage_limit_date) + { + if (is_null($outlet_storage_limit_date)) { + throw new \InvalidArgumentException('non-nullable outlet_storage_limit_date cannot be null'); + } + $this->container['outlet_storage_limit_date'] = $outlet_storage_limit_date; + + return $this; + } + + /** + * Gets dispatch_type + * + * @return \OpenAPI\Client\Model\OrderDeliveryDispatchType|null + */ + public function getDispatchType() + { + return $this->container['dispatch_type']; + } + + /** + * Sets dispatch_type + * + * @param \OpenAPI\Client\Model\OrderDeliveryDispatchType|null $dispatch_type dispatch_type + * + * @return self + */ + public function setDispatchType($dispatch_type) + { + if (is_null($dispatch_type)) { + throw new \InvalidArgumentException('non-nullable dispatch_type cannot be null'); + } + $this->container['dispatch_type'] = $dispatch_type; + + return $this; + } + + /** + * Gets tracks + * + * @return \OpenAPI\Client\Model\OrderTrackDTO[]|null + */ + public function getTracks() + { + return $this->container['tracks']; + } + + /** + * Sets tracks + * + * @param \OpenAPI\Client\Model\OrderTrackDTO[]|null $tracks Информация для отслеживания перемещений посылки. + * + * @return self + */ + public function setTracks($tracks) + { + if (is_null($tracks)) { + array_push($this->openAPINullablesSetToNull, 'tracks'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tracks', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tracks'] = $tracks; + + return $this; + } + + /** + * Gets shipments + * + * @return \OpenAPI\Client\Model\OrderShipmentDTO[]|null + */ + public function getShipments() + { + return $this->container['shipments']; + } + + /** + * Sets shipments + * + * @param \OpenAPI\Client\Model\OrderShipmentDTO[]|null $shipments Информация о посылках. + * + * @return self + */ + public function setShipments($shipments) + { + if (is_null($shipments)) { + array_push($this->openAPINullablesSetToNull, 'shipments'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('shipments', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['shipments'] = $shipments; + + return $this; + } + + /** + * Gets estimated + * + * @return bool|null + */ + public function getEstimated() + { + return $this->container['estimated']; + } + + /** + * Sets estimated + * + * @param bool|null $estimated Приблизительная ли дата доставки. + * + * @return self + */ + public function setEstimated($estimated) + { + if (is_null($estimated)) { + throw new \InvalidArgumentException('non-nullable estimated cannot be null'); + } + $this->container['estimated'] = $estimated; + + return $this; + } + + /** + * Gets eac_type + * + * @return \OpenAPI\Client\Model\OrderDeliveryEacType|null + */ + public function getEacType() + { + return $this->container['eac_type']; + } + + /** + * Sets eac_type + * + * @param \OpenAPI\Client\Model\OrderDeliveryEacType|null $eac_type eac_type + * + * @return self + */ + public function setEacType($eac_type) + { + if (is_null($eac_type)) { + throw new \InvalidArgumentException('non-nullable eac_type cannot be null'); + } + $this->container['eac_type'] = $eac_type; + + return $this; + } + + /** + * Gets eac_code + * + * @return string|null + */ + public function getEacCode() + { + return $this->container['eac_code']; + } + + /** + * Sets eac_code + * + * @param string|null $eac_code Код подтверждения ЭАПП (для типа `MERCHANT_TO_COURIER`). + * + * @return self + */ + public function setEacCode($eac_code) + { + if (is_null($eac_code)) { + throw new \InvalidArgumentException('non-nullable eac_code cannot be null'); + } + $this->container['eac_code'] = $eac_code; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderDeliveryDateDTO.php b/erp24/lib/yandex_market_api/Model/OrderDeliveryDateDTO.php new file mode 100644 index 00000000..7a0d479e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderDeliveryDateDTO.php @@ -0,0 +1,413 @@ + + */ +class OrderDeliveryDateDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderDeliveryDateDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'to_date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'to_date' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'to_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'to_date' => 'toDate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'to_date' => 'setToDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'to_date' => 'getToDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('to_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['to_date'] === null) { + $invalidProperties[] = "'to_date' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets to_date + * + * @return \DateTime + */ + public function getToDate() + { + return $this->container['to_date']; + } + + /** + * Sets to_date + * + * @param \DateTime $to_date Новая дата доставки заказа. Формат даты: `ГГГГ-ММ-ДД`. + * + * @return self + */ + public function setToDate($to_date) + { + if (is_null($to_date)) { + throw new \InvalidArgumentException('non-nullable to_date cannot be null'); + } + $this->container['to_date'] = $to_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderDeliveryDateReasonType.php b/erp24/lib/yandex_market_api/Model/OrderDeliveryDateReasonType.php new file mode 100644 index 00000000..052eedc7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderDeliveryDateReasonType.php @@ -0,0 +1,63 @@ + + */ +class OrderDeliveryDatesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderDeliveryDatesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'from_date' => 'string', + 'to_date' => 'string', + 'from_time' => 'string', + 'to_time' => 'string', + 'real_delivery_date' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'from_date' => 'date-dd-MM-yyyy', + 'to_date' => 'date-dd-MM-yyyy', + 'from_time' => 'time', + 'to_time' => 'time', + 'real_delivery_date' => 'date-dd-MM-yyyy' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'from_date' => false, + 'to_date' => false, + 'from_time' => false, + 'to_time' => false, + 'real_delivery_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'from_date' => 'fromDate', + 'to_date' => 'toDate', + 'from_time' => 'fromTime', + 'to_time' => 'toTime', + 'real_delivery_date' => 'realDeliveryDate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'from_date' => 'setFromDate', + 'to_date' => 'setToDate', + 'from_time' => 'setFromTime', + 'to_time' => 'setToTime', + 'real_delivery_date' => 'setRealDeliveryDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'from_date' => 'getFromDate', + 'to_date' => 'getToDate', + 'from_time' => 'getFromTime', + 'to_time' => 'getToTime', + 'real_delivery_date' => 'getRealDeliveryDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('from_date', $data ?? [], null); + $this->setIfExists('to_date', $data ?? [], null); + $this->setIfExists('from_time', $data ?? [], null); + $this->setIfExists('to_time', $data ?? [], null); + $this->setIfExists('real_delivery_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets from_date + * + * @return string|null + */ + public function getFromDate() + { + return $this->container['from_date']; + } + + /** + * Sets from_date + * + * @param string|null $from_date Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setFromDate($from_date) + { + if (is_null($from_date)) { + throw new \InvalidArgumentException('non-nullable from_date cannot be null'); + } + $this->container['from_date'] = $from_date; + + return $this; + } + + /** + * Gets to_date + * + * @return string|null + */ + public function getToDate() + { + return $this->container['to_date']; + } + + /** + * Sets to_date + * + * @param string|null $to_date Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setToDate($to_date) + { + if (is_null($to_date)) { + throw new \InvalidArgumentException('non-nullable to_date cannot be null'); + } + $this->container['to_date'] = $to_date; + + return $this; + } + + /** + * Gets from_time + * + * @return string|null + */ + public function getFromTime() + { + return $this->container['from_time']; + } + + /** + * Sets from_time + * + * @param string|null $from_time Начало интервала времени доставки. Передается только совместно с параметром `type=DELIVERY`. Формат времени: 24-часовой, `ЧЧ:ММ`. В качестве минут всегда должно быть указано `00` (исключение — `23:59`). Минимальное значение: `00:00`. + * + * @return self + */ + public function setFromTime($from_time) + { + if (is_null($from_time)) { + throw new \InvalidArgumentException('non-nullable from_time cannot be null'); + } + $this->container['from_time'] = $from_time; + + return $this; + } + + /** + * Gets to_time + * + * @return string|null + */ + public function getToTime() + { + return $this->container['to_time']; + } + + /** + * Sets to_time + * + * @param string|null $to_time Конец интервала времени доставки. Передается только совместно с параметром `type=DELIVERY`. Формат времени: 24-часовой, `ЧЧ:ММ`. В качестве минут всегда должно быть указано `00` (исключение — `23:59`). Максимальное значение: `23:59`. + * + * @return self + */ + public function setToTime($to_time) + { + if (is_null($to_time)) { + throw new \InvalidArgumentException('non-nullable to_time cannot be null'); + } + $this->container['to_time'] = $to_time; + + return $this; + } + + /** + * Gets real_delivery_date + * + * @return string|null + */ + public function getRealDeliveryDate() + { + return $this->container['real_delivery_date']; + } + + /** + * Sets real_delivery_date + * + * @param string|null $real_delivery_date Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setRealDeliveryDate($real_delivery_date) + { + if (is_null($real_delivery_date)) { + throw new \InvalidArgumentException('non-nullable real_delivery_date cannot be null'); + } + $this->container['real_delivery_date'] = $real_delivery_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderDeliveryDispatchType.php b/erp24/lib/yandex_market_api/Model/OrderDeliveryDispatchType.php new file mode 100644 index 00000000..48526d79 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderDeliveryDispatchType.php @@ -0,0 +1,69 @@ + + */ +class OrderDigitalItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderDigitalItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'code' => 'string', + 'slip' => 'string', + 'activate_till' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'code' => null, + 'slip' => null, + 'activate_till' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'code' => false, + 'slip' => false, + 'activate_till' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'code' => 'code', + 'slip' => 'slip', + 'activate_till' => 'activate_till' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'code' => 'setCode', + 'slip' => 'setSlip', + 'activate_till' => 'setActivateTill' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'code' => 'getCode', + 'slip' => 'getSlip', + 'activate_till' => 'getActivateTill' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('code', $data ?? [], null); + $this->setIfExists('slip', $data ?? [], null); + $this->setIfExists('activate_till', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['code'] === null) { + $invalidProperties[] = "'code' can't be null"; + } + if ($this->container['slip'] === null) { + $invalidProperties[] = "'slip' can't be null"; + } + if ($this->container['activate_till'] === null) { + $invalidProperties[] = "'activate_till' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор товара в заказе. Он приходит в ответе на запрос [GET campaigns/{campaignId}/orders/{orderId}](../../reference/orders/getOrder.md) и в запросе Маркета [POST order/accept](../../pushapi/reference/orderAccept.md) — параметр `id` в `items`. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets code + * + * @return string + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string $code Сам ключ. + * + * @return self + */ + public function setCode($code) + { + if (is_null($code)) { + throw new \InvalidArgumentException('non-nullable code cannot be null'); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets slip + * + * @return string + */ + public function getSlip() + { + return $this->container['slip']; + } + + /** + * Sets slip + * + * @param string $slip Инструкция по активации. + * + * @return self + */ + public function setSlip($slip) + { + if (is_null($slip)) { + throw new \InvalidArgumentException('non-nullable slip cannot be null'); + } + $this->container['slip'] = $slip; + + return $this; + } + + /** + * Gets activate_till + * + * @return \DateTime + */ + public function getActivateTill() + { + return $this->container['activate_till']; + } + + /** + * Sets activate_till + * + * @param \DateTime $activate_till Дата, до которой нужно активировать ключ. Если ключ действует бессрочно, укажите любую дату в отдаленном будущем. Формат даты: `ГГГГ-ММ-ДД`. + * + * @return self + */ + public function setActivateTill($activate_till) + { + if (is_null($activate_till)) { + throw new \InvalidArgumentException('non-nullable activate_till cannot be null'); + } + $this->container['activate_till'] = $activate_till; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderDocumentStatusType.php b/erp24/lib/yandex_market_api/Model/OrderDocumentStatusType.php new file mode 100644 index 00000000..1de10968 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderDocumentStatusType.php @@ -0,0 +1,63 @@ + + */ +class OrderItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'offer_id' => 'string', + 'offer_name' => 'string', + 'price' => 'float', + 'buyer_price' => 'float', + 'buyer_price_before_discount' => 'float', + 'price_before_discount' => 'float', + 'count' => 'int', + 'vat' => '\OpenAPI\Client\Model\OrderVatType', + 'shop_sku' => 'string', + 'subsidy' => 'float', + 'partner_warehouse_id' => 'string', + 'promos' => '\OpenAPI\Client\Model\OrderItemPromoDTO[]', + 'instances' => '\OpenAPI\Client\Model\OrderItemInstanceDTO[]', + 'details' => '\OpenAPI\Client\Model\OrderItemDetailDTO[]', + 'subsidies' => '\OpenAPI\Client\Model\OrderItemSubsidyDTO[]', + 'required_instance_types' => '\OpenAPI\Client\Model\OrderItemInstanceType[]', + 'tags' => '\OpenAPI\Client\Model\OrderItemTagType[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'offer_id' => null, + 'offer_name' => null, + 'price' => 'decimal', + 'buyer_price' => 'decimal', + 'buyer_price_before_discount' => 'decimal', + 'price_before_discount' => 'decimal', + 'count' => null, + 'vat' => null, + 'shop_sku' => null, + 'subsidy' => 'decimal', + 'partner_warehouse_id' => null, + 'promos' => null, + 'instances' => null, + 'details' => null, + 'subsidies' => null, + 'required_instance_types' => null, + 'tags' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'offer_id' => false, + 'offer_name' => false, + 'price' => false, + 'buyer_price' => false, + 'buyer_price_before_discount' => false, + 'price_before_discount' => false, + 'count' => false, + 'vat' => false, + 'shop_sku' => false, + 'subsidy' => false, + 'partner_warehouse_id' => false, + 'promos' => true, + 'instances' => true, + 'details' => true, + 'subsidies' => true, + 'required_instance_types' => true, + 'tags' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'offer_id' => 'offerId', + 'offer_name' => 'offerName', + 'price' => 'price', + 'buyer_price' => 'buyerPrice', + 'buyer_price_before_discount' => 'buyerPriceBeforeDiscount', + 'price_before_discount' => 'priceBeforeDiscount', + 'count' => 'count', + 'vat' => 'vat', + 'shop_sku' => 'shopSku', + 'subsidy' => 'subsidy', + 'partner_warehouse_id' => 'partnerWarehouseId', + 'promos' => 'promos', + 'instances' => 'instances', + 'details' => 'details', + 'subsidies' => 'subsidies', + 'required_instance_types' => 'requiredInstanceTypes', + 'tags' => 'tags' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'offer_id' => 'setOfferId', + 'offer_name' => 'setOfferName', + 'price' => 'setPrice', + 'buyer_price' => 'setBuyerPrice', + 'buyer_price_before_discount' => 'setBuyerPriceBeforeDiscount', + 'price_before_discount' => 'setPriceBeforeDiscount', + 'count' => 'setCount', + 'vat' => 'setVat', + 'shop_sku' => 'setShopSku', + 'subsidy' => 'setSubsidy', + 'partner_warehouse_id' => 'setPartnerWarehouseId', + 'promos' => 'setPromos', + 'instances' => 'setInstances', + 'details' => 'setDetails', + 'subsidies' => 'setSubsidies', + 'required_instance_types' => 'setRequiredInstanceTypes', + 'tags' => 'setTags' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'offer_id' => 'getOfferId', + 'offer_name' => 'getOfferName', + 'price' => 'getPrice', + 'buyer_price' => 'getBuyerPrice', + 'buyer_price_before_discount' => 'getBuyerPriceBeforeDiscount', + 'price_before_discount' => 'getPriceBeforeDiscount', + 'count' => 'getCount', + 'vat' => 'getVat', + 'shop_sku' => 'getShopSku', + 'subsidy' => 'getSubsidy', + 'partner_warehouse_id' => 'getPartnerWarehouseId', + 'promos' => 'getPromos', + 'instances' => 'getInstances', + 'details' => 'getDetails', + 'subsidies' => 'getSubsidies', + 'required_instance_types' => 'getRequiredInstanceTypes', + 'tags' => 'getTags' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('offer_name', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('buyer_price', $data ?? [], null); + $this->setIfExists('buyer_price_before_discount', $data ?? [], null); + $this->setIfExists('price_before_discount', $data ?? [], null); + $this->setIfExists('count', $data ?? [], null); + $this->setIfExists('vat', $data ?? [], null); + $this->setIfExists('shop_sku', $data ?? [], null); + $this->setIfExists('subsidy', $data ?? [], null); + $this->setIfExists('partner_warehouse_id', $data ?? [], null); + $this->setIfExists('promos', $data ?? [], null); + $this->setIfExists('instances', $data ?? [], null); + $this->setIfExists('details', $data ?? [], null); + $this->setIfExists('subsidies', $data ?? [], null); + $this->setIfExists('required_instance_types', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор товара в заказе. Позволяет идентифицировать товар в рамках данного заказа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OrderItemDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling OrderItemDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling OrderItemDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets offer_name + * + * @return string|null + */ + public function getOfferName() + { + return $this->container['offer_name']; + } + + /** + * Sets offer_name + * + * @param string|null $offer_name Название товара. + * + * @return self + */ + public function setOfferName($offer_name) + { + if (is_null($offer_name)) { + throw new \InvalidArgumentException('non-nullable offer_name cannot be null'); + } + $this->container['offer_name'] = $offer_name; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price Цена на товар в валюте заказа без учета вознаграждения партнеру за скидки по промокодам, купонам и акциям (параметр `subsidies`). + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets buyer_price + * + * @return float|null + */ + public function getBuyerPrice() + { + return $this->container['buyer_price']; + } + + /** + * Sets buyer_price + * + * @param float|null $buyer_price Цена на товар в валюте покупателя. В цене уже учтены скидки по: * акциям; * купонам; * промокодам. + * + * @return self + */ + public function setBuyerPrice($buyer_price) + { + if (is_null($buyer_price)) { + throw new \InvalidArgumentException('non-nullable buyer_price cannot be null'); + } + $this->container['buyer_price'] = $buyer_price; + + return $this; + } + + /** + * Gets buyer_price_before_discount + * + * @return float|null + */ + public function getBuyerPriceBeforeDiscount() + { + return $this->container['buyer_price_before_discount']; + } + + /** + * Sets buyer_price_before_discount + * + * @param float|null $buyer_price_before_discount Стоимость товара в валюте покупателя до применения скидок по: * акциям; * купонам; * промокодам. + * + * @return self + */ + public function setBuyerPriceBeforeDiscount($buyer_price_before_discount) + { + if (is_null($buyer_price_before_discount)) { + throw new \InvalidArgumentException('non-nullable buyer_price_before_discount cannot be null'); + } + $this->container['buyer_price_before_discount'] = $buyer_price_before_discount; + + return $this; + } + + /** + * Gets price_before_discount + * + * @return float|null + * @deprecated + */ + public function getPriceBeforeDiscount() + { + return $this->container['price_before_discount']; + } + + /** + * Sets price_before_discount + * + * @param float|null $price_before_discount {% note warning \"\" %} Этот параметр устарел. {% endnote %} Стоимость товара в валюте магазина до применения скидок. + * + * @return self + * @deprecated + */ + public function setPriceBeforeDiscount($price_before_discount) + { + if (is_null($price_before_discount)) { + throw new \InvalidArgumentException('non-nullable price_before_discount cannot be null'); + } + $this->container['price_before_discount'] = $price_before_discount; + + return $this; + } + + /** + * Gets count + * + * @return int|null + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param int|null $count Количество единиц товара. + * + * @return self + */ + public function setCount($count) + { + if (is_null($count)) { + throw new \InvalidArgumentException('non-nullable count cannot be null'); + } + $this->container['count'] = $count; + + return $this; + } + + /** + * Gets vat + * + * @return \OpenAPI\Client\Model\OrderVatType|null + */ + public function getVat() + { + return $this->container['vat']; + } + + /** + * Sets vat + * + * @param \OpenAPI\Client\Model\OrderVatType|null $vat vat + * + * @return self + */ + public function setVat($vat) + { + if (is_null($vat)) { + throw new \InvalidArgumentException('non-nullable vat cannot be null'); + } + $this->container['vat'] = $vat; + + return $this; + } + + /** + * Gets shop_sku + * + * @return string|null + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string|null $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling OrderItemDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling OrderItemDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling OrderItemDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + + /** + * Gets subsidy + * + * @return float|null + * @deprecated + */ + public function getSubsidy() + { + return $this->container['subsidy']; + } + + /** + * Sets subsidy + * + * @param float|null $subsidy {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `subsidies`. {% endnote %} Общее вознаграждение партнеру за DBS-доставку и все скидки на товар: * по промокодам; * по купонам; * по баллам Плюса; * по акциям. Передается в валюте заказа. + * + * @return self + * @deprecated + */ + public function setSubsidy($subsidy) + { + if (is_null($subsidy)) { + throw new \InvalidArgumentException('non-nullable subsidy cannot be null'); + } + $this->container['subsidy'] = $subsidy; + + return $this; + } + + /** + * Gets partner_warehouse_id + * + * @return string|null + * @deprecated + */ + public function getPartnerWarehouseId() + { + return $this->container['partner_warehouse_id']; + } + + /** + * Sets partner_warehouse_id + * + * @param string|null $partner_warehouse_id {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Идентификатор склада в системе партнера, на который сформирован заказ. + * + * @return self + * @deprecated + */ + public function setPartnerWarehouseId($partner_warehouse_id) + { + if (is_null($partner_warehouse_id)) { + throw new \InvalidArgumentException('non-nullable partner_warehouse_id cannot be null'); + } + $this->container['partner_warehouse_id'] = $partner_warehouse_id; + + return $this; + } + + /** + * Gets promos + * + * @return \OpenAPI\Client\Model\OrderItemPromoDTO[]|null + */ + public function getPromos() + { + return $this->container['promos']; + } + + /** + * Sets promos + * + * @param \OpenAPI\Client\Model\OrderItemPromoDTO[]|null $promos Информация о вознаграждениях партнеру за скидки на товар по промокодам, купонам и акциям. + * + * @return self + */ + public function setPromos($promos) + { + if (is_null($promos)) { + array_push($this->openAPINullablesSetToNull, 'promos'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('promos', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['promos'] = $promos; + + return $this; + } + + /** + * Gets instances + * + * @return \OpenAPI\Client\Model\OrderItemInstanceDTO[]|null + */ + public function getInstances() + { + return $this->container['instances']; + } + + /** + * Sets instances + * + * @param \OpenAPI\Client\Model\OrderItemInstanceDTO[]|null $instances Информация о маркировке единиц товара. Возвращаются данные для маркировки, переданные в запросе [PUT campaigns/{campaignId}/orders/{orderId}/cis](../../reference/orders/provideOrderItemCis.md). Если магазин еще не передавал коды для этого заказа, `instances` отсутствует. + * + * @return self + */ + public function setInstances($instances) + { + if (is_null($instances)) { + array_push($this->openAPINullablesSetToNull, 'instances'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('instances', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['instances'] = $instances; + + return $this; + } + + /** + * Gets details + * + * @return \OpenAPI\Client\Model\OrderItemDetailDTO[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \OpenAPI\Client\Model\OrderItemDetailDTO[]|null $details Информация об удалении товара из заказа. + * + * @return self + */ + public function setDetails($details) + { + if (is_null($details)) { + array_push($this->openAPINullablesSetToNull, 'details'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('details', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['details'] = $details; + + return $this; + } + + /** + * Gets subsidies + * + * @return \OpenAPI\Client\Model\OrderItemSubsidyDTO[]|null + */ + public function getSubsidies() + { + return $this->container['subsidies']; + } + + /** + * Sets subsidies + * + * @param \OpenAPI\Client\Model\OrderItemSubsidyDTO[]|null $subsidies Список субсидий по типам. + * + * @return self + */ + public function setSubsidies($subsidies) + { + if (is_null($subsidies)) { + array_push($this->openAPINullablesSetToNull, 'subsidies'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('subsidies', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['subsidies'] = $subsidies; + + return $this; + } + + /** + * Gets required_instance_types + * + * @return \OpenAPI\Client\Model\OrderItemInstanceType[]|null + */ + public function getRequiredInstanceTypes() + { + return $this->container['required_instance_types']; + } + + /** + * Sets required_instance_types + * + * @param \OpenAPI\Client\Model\OrderItemInstanceType[]|null $required_instance_types Список необходимых маркировок товара. + * + * @return self + */ + public function setRequiredInstanceTypes($required_instance_types) + { + if (is_null($required_instance_types)) { + array_push($this->openAPINullablesSetToNull, 'required_instance_types'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('required_instance_types', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['required_instance_types'] = $required_instance_types; + + return $this; + } + + /** + * Gets tags + * + * @return \OpenAPI\Client\Model\OrderItemTagType[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param \OpenAPI\Client\Model\OrderItemTagType[]|null $tags Признаки товара. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + array_push($this->openAPINullablesSetToNull, 'tags'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tags', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tags'] = $tags; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderItemDetailDTO.php b/erp24/lib/yandex_market_api/Model/OrderItemDetailDTO.php new file mode 100644 index 00000000..f31318ba --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderItemDetailDTO.php @@ -0,0 +1,478 @@ + + */ +class OrderItemDetailDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderItemDetailDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'item_count' => 'int', + 'item_status' => '\OpenAPI\Client\Model\OrderItemStatusType', + 'update_date' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'item_count' => 'int64', + 'item_status' => null, + 'update_date' => 'date-dd-MM-yyyy' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'item_count' => false, + 'item_status' => false, + 'update_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'item_count' => 'itemCount', + 'item_status' => 'itemStatus', + 'update_date' => 'updateDate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'item_count' => 'setItemCount', + 'item_status' => 'setItemStatus', + 'update_date' => 'setUpdateDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'item_count' => 'getItemCount', + 'item_status' => 'getItemStatus', + 'update_date' => 'getUpdateDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('item_count', $data ?? [], null); + $this->setIfExists('item_status', $data ?? [], null); + $this->setIfExists('update_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets item_count + * + * @return int|null + */ + public function getItemCount() + { + return $this->container['item_count']; + } + + /** + * Sets item_count + * + * @param int|null $item_count Количество единиц товара. + * + * @return self + */ + public function setItemCount($item_count) + { + if (is_null($item_count)) { + throw new \InvalidArgumentException('non-nullable item_count cannot be null'); + } + $this->container['item_count'] = $item_count; + + return $this; + } + + /** + * Gets item_status + * + * @return \OpenAPI\Client\Model\OrderItemStatusType|null + */ + public function getItemStatus() + { + return $this->container['item_status']; + } + + /** + * Sets item_status + * + * @param \OpenAPI\Client\Model\OrderItemStatusType|null $item_status item_status + * + * @return self + */ + public function setItemStatus($item_status) + { + if (is_null($item_status)) { + throw new \InvalidArgumentException('non-nullable item_status cannot be null'); + } + $this->container['item_status'] = $item_status; + + return $this; + } + + /** + * Gets update_date + * + * @return string|null + */ + public function getUpdateDate() + { + return $this->container['update_date']; + } + + /** + * Sets update_date + * + * @param string|null $update_date Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setUpdateDate($update_date) + { + if (is_null($update_date)) { + throw new \InvalidArgumentException('non-nullable update_date cannot be null'); + } + $this->container['update_date'] = $update_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderItemInstanceDTO.php b/erp24/lib/yandex_market_api/Model/OrderItemInstanceDTO.php new file mode 100644 index 00000000..f2c4e436 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderItemInstanceDTO.php @@ -0,0 +1,546 @@ + + */ +class OrderItemInstanceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderItemInstanceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'cis' => 'string', + 'cis_full' => 'string', + 'uin' => 'string', + 'rnpt' => 'string', + 'gtd' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'cis' => null, + 'cis_full' => null, + 'uin' => null, + 'rnpt' => null, + 'gtd' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'cis' => false, + 'cis_full' => false, + 'uin' => false, + 'rnpt' => false, + 'gtd' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'cis' => 'cis', + 'cis_full' => 'cisFull', + 'uin' => 'uin', + 'rnpt' => 'rnpt', + 'gtd' => 'gtd' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'cis' => 'setCis', + 'cis_full' => 'setCisFull', + 'uin' => 'setUin', + 'rnpt' => 'setRnpt', + 'gtd' => 'setGtd' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'cis' => 'getCis', + 'cis_full' => 'getCisFull', + 'uin' => 'getUin', + 'rnpt' => 'getRnpt', + 'gtd' => 'getGtd' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('cis', $data ?? [], null); + $this->setIfExists('cis_full', $data ?? [], null); + $this->setIfExists('uin', $data ?? [], null); + $this->setIfExists('rnpt', $data ?? [], null); + $this->setIfExists('gtd', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets cis + * + * @return string|null + */ + public function getCis() + { + return $this->container['cis']; + } + + /** + * Sets cis + * + * @param string|null $cis Код идентификации единицы товара [в системе «Честный ЗНАК»](https://честныйзнак.рф/) без криптохвоста. + * + * @return self + */ + public function setCis($cis) + { + if (is_null($cis)) { + throw new \InvalidArgumentException('non-nullable cis cannot be null'); + } + $this->container['cis'] = $cis; + + return $this; + } + + /** + * Gets cis_full + * + * @return string|null + */ + public function getCisFull() + { + return $this->container['cis_full']; + } + + /** + * Sets cis_full + * + * @param string|null $cis_full Код идентификации единицы товара [в системе «Честный ЗНАК»](https://честныйзнак.рф/) с криптохвостом. + * + * @return self + */ + public function setCisFull($cis_full) + { + if (is_null($cis_full)) { + throw new \InvalidArgumentException('non-nullable cis_full cannot be null'); + } + $this->container['cis_full'] = $cis_full; + + return $this; + } + + /** + * Gets uin + * + * @return string|null + */ + public function getUin() + { + return $this->container['uin']; + } + + /** + * Sets uin + * + * @param string|null $uin УИН ювелирного изделия (16-значный код) Производитель получает УИН, когда регистрирует изделие в системе контроля за оборотом драгоценных металлов и камней — ГИИС ДМДК. + * + * @return self + */ + public function setUin($uin) + { + if (is_null($uin)) { + throw new \InvalidArgumentException('non-nullable uin cannot be null'); + } + $this->container['uin'] = $uin; + + return $this; + } + + /** + * Gets rnpt + * + * @return string|null + */ + public function getRnpt() + { + return $this->container['rnpt']; + } + + /** + * Sets rnpt + * + * @param string|null $rnpt Регистрационный номер партии товара. Представляет собой строку из четырех чисел, разделенных косой чертой: ХХХХХХХХ/ХХХХХХ/ХХХХХХХ/ХХХ. Первая часть — код таможни, которая зарегистрировала декларацию на партию товара. Далее — дата, номер декларации и номер маркированного товара в декларации. + * + * @return self + */ + public function setRnpt($rnpt) + { + if (is_null($rnpt)) { + throw new \InvalidArgumentException('non-nullable rnpt cannot be null'); + } + $this->container['rnpt'] = $rnpt; + + return $this; + } + + /** + * Gets gtd + * + * @return string|null + */ + public function getGtd() + { + return $this->container['gtd']; + } + + /** + * Sets gtd + * + * @param string|null $gtd Грузовая таможенная декларация. Представляет собой строку из трех чисел, разделенных косой чертой: ХХХХХХХХ/ХХХХХХ/ХХХХХХХ. Первая часть — код таможни, которая зарегистрировала декларацию на ввезенные товары. Далее — дата и номер декларации. + * + * @return self + */ + public function setGtd($gtd) + { + if (is_null($gtd)) { + throw new \InvalidArgumentException('non-nullable gtd cannot be null'); + } + $this->container['gtd'] = $gtd; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderItemInstanceModificationDTO.php b/erp24/lib/yandex_market_api/Model/OrderItemInstanceModificationDTO.php new file mode 100644 index 00000000..cc38f1f3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderItemInstanceModificationDTO.php @@ -0,0 +1,450 @@ + + */ +class OrderItemInstanceModificationDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderItemInstanceModificationDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'instances' => '\OpenAPI\Client\Model\BriefOrderItemInstanceDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'instances' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'instances' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'instances' => 'instances' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'instances' => 'setInstances' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'instances' => 'getInstances' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('instances', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['instances'] === null) { + $invalidProperties[] = "'instances' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор товара в заказе. Он приходит в ответе на запрос [GET campaigns/{campaignId}/orders/{orderId}](../../reference/orders/getOrder.md) и в запросе Маркета [POST order/accept](../../pushapi/reference/orderAccept.md) — параметр `id` в `items`. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets instances + * + * @return \OpenAPI\Client\Model\BriefOrderItemInstanceDTO[] + */ + public function getInstances() + { + return $this->container['instances']; + } + + /** + * Sets instances + * + * @param \OpenAPI\Client\Model\BriefOrderItemInstanceDTO[] $instances Список кодов маркировки единиц товара. + * + * @return self + */ + public function setInstances($instances) + { + if (is_null($instances)) { + throw new \InvalidArgumentException('non-nullable instances cannot be null'); + } + $this->container['instances'] = $instances; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderItemInstanceType.php b/erp24/lib/yandex_market_api/Model/OrderItemInstanceType.php new file mode 100644 index 00000000..8d81b6d6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderItemInstanceType.php @@ -0,0 +1,72 @@ + + */ +class OrderItemModificationDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderItemModificationDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'count' => 'int', + 'instances' => '\OpenAPI\Client\Model\BriefOrderItemInstanceDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'count' => 'int32', + 'instances' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'count' => false, + 'instances' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'count' => 'count', + 'instances' => 'instances' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'count' => 'setCount', + 'instances' => 'setInstances' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'count' => 'getCount', + 'instances' => 'getInstances' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('count', $data ?? [], null); + $this->setIfExists('instances', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['count'] === null) { + $invalidProperties[] = "'count' can't be null"; + } + if (($this->container['count'] < 0)) { + $invalidProperties[] = "invalid value for 'count', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор товара в рамках заказа. Получить идентификатор можно с помощью ресурсов [GET campaigns/{campaignId}/orders](../../reference/orders/getOrders.md) или [GET campaigns/{campaignId}/orders/{orderId}](../../reference/orders/getOrder.md). Обязательный параметр. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets count + * + * @return int + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param int $count Новое количество товара. + * + * @return self + */ + public function setCount($count) + { + if (is_null($count)) { + throw new \InvalidArgumentException('non-nullable count cannot be null'); + } + + if (($count < 0)) { + throw new \InvalidArgumentException('invalid value for $count when calling OrderItemModificationDTO., must be bigger than or equal to 0.'); + } + + $this->container['count'] = $count; + + return $this; + } + + /** + * Gets instances + * + * @return \OpenAPI\Client\Model\BriefOrderItemInstanceDTO[]|null + */ + public function getInstances() + { + return $this->container['instances']; + } + + /** + * Sets instances + * + * @param \OpenAPI\Client\Model\BriefOrderItemInstanceDTO[]|null $instances Информация о маркировке единиц товара. Передавайте в запросе все единицы товара, который подлежит маркировке. Обязательный параметр, если в заказе есть товары, подлежащие маркировке [в системе «Честный ЗНАК»](https://честныйзнак.рф/). + * + * @return self + */ + public function setInstances($instances) + { + if (is_null($instances)) { + array_push($this->openAPINullablesSetToNull, 'instances'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('instances', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['instances'] = $instances; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderItemPromoDTO.php b/erp24/lib/yandex_market_api/Model/OrderItemPromoDTO.php new file mode 100644 index 00000000..b6b354ce --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderItemPromoDTO.php @@ -0,0 +1,549 @@ + + */ +class OrderItemPromoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderItemPromoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OrderPromoType', + 'discount' => 'float', + 'subsidy' => 'float', + 'shop_promo_id' => 'string', + 'market_promo_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'discount' => 'decimal', + 'subsidy' => 'decimal', + 'shop_promo_id' => null, + 'market_promo_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'discount' => false, + 'subsidy' => false, + 'shop_promo_id' => false, + 'market_promo_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'discount' => 'discount', + 'subsidy' => 'subsidy', + 'shop_promo_id' => 'shopPromoId', + 'market_promo_id' => 'marketPromoId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'discount' => 'setDiscount', + 'subsidy' => 'setSubsidy', + 'shop_promo_id' => 'setShopPromoId', + 'market_promo_id' => 'setMarketPromoId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'discount' => 'getDiscount', + 'subsidy' => 'getSubsidy', + 'shop_promo_id' => 'getShopPromoId', + 'market_promo_id' => 'getMarketPromoId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('discount', $data ?? [], null); + $this->setIfExists('subsidy', $data ?? [], null); + $this->setIfExists('shop_promo_id', $data ?? [], null); + $this->setIfExists('market_promo_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrderPromoType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrderPromoType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets discount + * + * @return float|null + */ + public function getDiscount() + { + return $this->container['discount']; + } + + /** + * Sets discount + * + * @param float|null $discount Размер пользовательской скидки в валюте покупателя. + * + * @return self + */ + public function setDiscount($discount) + { + if (is_null($discount)) { + throw new \InvalidArgumentException('non-nullable discount cannot be null'); + } + $this->container['discount'] = $discount; + + return $this; + } + + /** + * Gets subsidy + * + * @return float|null + */ + public function getSubsidy() + { + return $this->container['subsidy']; + } + + /** + * Sets subsidy + * + * @param float|null $subsidy Вознаграждение партнеру от Маркета за товар, проданный в рамках акции. Передается в валюте заказа. + * + * @return self + */ + public function setSubsidy($subsidy) + { + if (is_null($subsidy)) { + throw new \InvalidArgumentException('non-nullable subsidy cannot be null'); + } + $this->container['subsidy'] = $subsidy; + + return $this; + } + + /** + * Gets shop_promo_id + * + * @return string|null + */ + public function getShopPromoId() + { + return $this->container['shop_promo_id']; + } + + /** + * Sets shop_promo_id + * + * @param string|null $shop_promo_id Идентификатор акции поставщика. + * + * @return self + */ + public function setShopPromoId($shop_promo_id) + { + if (is_null($shop_promo_id)) { + throw new \InvalidArgumentException('non-nullable shop_promo_id cannot be null'); + } + $this->container['shop_promo_id'] = $shop_promo_id; + + return $this; + } + + /** + * Gets market_promo_id + * + * @return string|null + */ + public function getMarketPromoId() + { + return $this->container['market_promo_id']; + } + + /** + * Sets market_promo_id + * + * @param string|null $market_promo_id Идентификатор акции в рамках соглашения на оказание услуг по продвижению сервиса между Маркетом и партнером. Параметр передается, только если параметр `type=MARKET_DEAL`. + * + * @return self + */ + public function setMarketPromoId($market_promo_id) + { + if (is_null($market_promo_id)) { + throw new \InvalidArgumentException('non-nullable market_promo_id cannot be null'); + } + $this->container['market_promo_id'] = $market_promo_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderItemStatusType.php b/erp24/lib/yandex_market_api/Model/OrderItemStatusType.php new file mode 100644 index 00000000..38e37436 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderItemStatusType.php @@ -0,0 +1,63 @@ + + */ +class OrderItemSubsidyDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderItemSubsidyDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OrderItemSubsidyType', + 'amount' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'amount' => 'decimal' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'amount' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'amount' => 'amount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'amount' => 'setAmount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'amount' => 'getAmount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrderItemSubsidyType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrderItemSubsidyType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets amount + * + * @return float|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param float|null $amount Сумма субсидии. + * + * @return self + */ + public function setAmount($amount) + { + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + $this->container['amount'] = $amount; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderItemSubsidyType.php b/erp24/lib/yandex_market_api/Model/OrderItemSubsidyType.php new file mode 100644 index 00000000..d38a68e7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderItemSubsidyType.php @@ -0,0 +1,63 @@ + + */ +class OrderItemsModificationResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderItemsModificationResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\OpenAPI\Client\Model\BriefOrderItemDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'items' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('items', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\BriefOrderItemDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\BriefOrderItemDTO[] $items Список позиций в заказе, подлежащих маркировке. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderLabelDTO.php b/erp24/lib/yandex_market_api/Model/OrderLabelDTO.php new file mode 100644 index 00000000..c1affe10 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderLabelDTO.php @@ -0,0 +1,524 @@ + + */ +class OrderLabelDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderLabelDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order_id' => 'int', + 'places_number' => 'int', + 'url' => 'string', + 'parcel_box_labels' => '\OpenAPI\Client\Model\ParcelBoxLabelDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order_id' => 'int64', + 'places_number' => 'int32', + 'url' => null, + 'parcel_box_labels' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order_id' => false, + 'places_number' => false, + 'url' => false, + 'parcel_box_labels' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order_id' => 'orderId', + 'places_number' => 'placesNumber', + 'url' => 'url', + 'parcel_box_labels' => 'parcelBoxLabels' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order_id' => 'setOrderId', + 'places_number' => 'setPlacesNumber', + 'url' => 'setUrl', + 'parcel_box_labels' => 'setParcelBoxLabels' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order_id' => 'getOrderId', + 'places_number' => 'getPlacesNumber', + 'url' => 'getUrl', + 'parcel_box_labels' => 'getParcelBoxLabels' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order_id', $data ?? [], null); + $this->setIfExists('places_number', $data ?? [], null); + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('parcel_box_labels', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['order_id'] === null) { + $invalidProperties[] = "'order_id' can't be null"; + } + if ($this->container['places_number'] === null) { + $invalidProperties[] = "'places_number' can't be null"; + } + if ($this->container['url'] === null) { + $invalidProperties[] = "'url' can't be null"; + } + if ($this->container['parcel_box_labels'] === null) { + $invalidProperties[] = "'parcel_box_labels' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order_id + * + * @return int + */ + public function getOrderId() + { + return $this->container['order_id']; + } + + /** + * Sets order_id + * + * @param int $order_id Идентификатор заказа. + * + * @return self + */ + public function setOrderId($order_id) + { + if (is_null($order_id)) { + throw new \InvalidArgumentException('non-nullable order_id cannot be null'); + } + $this->container['order_id'] = $order_id; + + return $this; + } + + /** + * Gets places_number + * + * @return int + */ + public function getPlacesNumber() + { + return $this->container['places_number']; + } + + /** + * Sets places_number + * + * @param int $places_number Количество коробок в заказе. + * + * @return self + */ + public function setPlacesNumber($places_number) + { + if (is_null($places_number)) { + throw new \InvalidArgumentException('non-nullable places_number cannot be null'); + } + $this->container['places_number'] = $places_number; + + return $this; + } + + /** + * Gets url + * + * @return string + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string $url URL файла с ярлыками‑наклейками на все коробки в заказе. Соответствует URL, по которому выполняется запрос [GET campaigns/{campaignId}/orders/{orderId}/delivery/labels](../../reference/orders/generateOrderLabels.md). + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets parcel_box_labels + * + * @return \OpenAPI\Client\Model\ParcelBoxLabelDTO[] + */ + public function getParcelBoxLabels() + { + return $this->container['parcel_box_labels']; + } + + /** + * Sets parcel_box_labels + * + * @param \OpenAPI\Client\Model\ParcelBoxLabelDTO[] $parcel_box_labels Информация на ярлыке. + * + * @return self + */ + public function setParcelBoxLabels($parcel_box_labels) + { + if (is_null($parcel_box_labels)) { + throw new \InvalidArgumentException('non-nullable parcel_box_labels cannot be null'); + } + $this->container['parcel_box_labels'] = $parcel_box_labels; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderLiftType.php b/erp24/lib/yandex_market_api/Model/OrderLiftType.php new file mode 100644 index 00000000..13e76202 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderLiftType.php @@ -0,0 +1,75 @@ + + */ +class OrderParcelBoxDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderParcelBoxDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'fulfilment_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'fulfilment_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'fulfilment_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'fulfilment_id' => 'fulfilmentId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'fulfilment_id' => 'setFulfilmentId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'fulfilment_id' => 'getFulfilmentId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('fulfilment_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор грузоместа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets fulfilment_id + * + * @return string|null + */ + public function getFulfilmentId() + { + return $this->container['fulfilment_id']; + } + + /** + * Sets fulfilment_id + * + * @param string|null $fulfilment_id Идентификатор грузового места в информационной системе магазина. + * + * @return self + */ + public function setFulfilmentId($fulfilment_id) + { + if (is_null($fulfilment_id)) { + throw new \InvalidArgumentException('non-nullable fulfilment_id cannot be null'); + } + $this->container['fulfilment_id'] = $fulfilment_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderPaymentMethodType.php b/erp24/lib/yandex_market_api/Model/OrderPaymentMethodType.php new file mode 100644 index 00000000..742078ad --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderPaymentMethodType.php @@ -0,0 +1,99 @@ + + */ +class OrderShipmentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderShipmentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'shipment_date' => 'string', + 'shipment_time' => 'string', + 'tracks' => '\OpenAPI\Client\Model\OrderTrackDTO[]', + 'boxes' => '\OpenAPI\Client\Model\OrderParcelBoxDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'shipment_date' => 'date-dd-MM-yyyy', + 'shipment_time' => null, + 'tracks' => null, + 'boxes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'shipment_date' => false, + 'shipment_time' => false, + 'tracks' => true, + 'boxes' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'shipment_date' => 'shipmentDate', + 'shipment_time' => 'shipmentTime', + 'tracks' => 'tracks', + 'boxes' => 'boxes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'shipment_date' => 'setShipmentDate', + 'shipment_time' => 'setShipmentTime', + 'tracks' => 'setTracks', + 'boxes' => 'setBoxes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'shipment_date' => 'getShipmentDate', + 'shipment_time' => 'getShipmentTime', + 'tracks' => 'getTracks', + 'boxes' => 'getBoxes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('shipment_date', $data ?? [], null); + $this->setIfExists('shipment_time', $data ?? [], null); + $this->setIfExists('tracks', $data ?? [], null); + $this->setIfExists('boxes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор посылки, присвоенный Маркетом. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets shipment_date + * + * @return string|null + */ + public function getShipmentDate() + { + return $this->container['shipment_date']; + } + + /** + * Sets shipment_date + * + * @param string|null $shipment_date Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setShipmentDate($shipment_date) + { + if (is_null($shipment_date)) { + throw new \InvalidArgumentException('non-nullable shipment_date cannot be null'); + } + $this->container['shipment_date'] = $shipment_date; + + return $this; + } + + /** + * Gets shipment_time + * + * @return string|null + */ + public function getShipmentTime() + { + return $this->container['shipment_time']; + } + + /** + * Sets shipment_time + * + * @param string|null $shipment_time **Только для модели Экспресс** Время, к которому магазин должен упаковать заказ и перевести его в статус `READY_TO_SHIP`. После смены статуса за заказом приедет курьер. Поле может появиться не сразу. Запрашивайте информацию о заказе в течении 5–10 минут, пока оно не вернется. Формат времени: 24-часовой, `ЧЧ:ММ`. Если заказ сделан организацией, параметр не возвращается до согласования даты доставки. + * + * @return self + */ + public function setShipmentTime($shipment_time) + { + if (is_null($shipment_time)) { + throw new \InvalidArgumentException('non-nullable shipment_time cannot be null'); + } + $this->container['shipment_time'] = $shipment_time; + + return $this; + } + + /** + * Gets tracks + * + * @return \OpenAPI\Client\Model\OrderTrackDTO[]|null + */ + public function getTracks() + { + return $this->container['tracks']; + } + + /** + * Sets tracks + * + * @param \OpenAPI\Client\Model\OrderTrackDTO[]|null $tracks **Только для модели DBS** Информация для отслеживания перемещений посылки. + * + * @return self + */ + public function setTracks($tracks) + { + if (is_null($tracks)) { + array_push($this->openAPINullablesSetToNull, 'tracks'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tracks', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tracks'] = $tracks; + + return $this; + } + + /** + * Gets boxes + * + * @return \OpenAPI\Client\Model\OrderParcelBoxDTO[]|null + */ + public function getBoxes() + { + return $this->container['boxes']; + } + + /** + * Sets boxes + * + * @param \OpenAPI\Client\Model\OrderParcelBoxDTO[]|null $boxes Список грузовых мест. + * + * @return self + */ + public function setBoxes($boxes) + { + if (is_null($boxes)) { + array_push($this->openAPINullablesSetToNull, 'boxes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('boxes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['boxes'] = $boxes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderStateDTO.php b/erp24/lib/yandex_market_api/Model/OrderStateDTO.php new file mode 100644 index 00000000..10f6f323 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderStateDTO.php @@ -0,0 +1,484 @@ + + */ +class OrderStateDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderStateDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'status' => '\OpenAPI\Client\Model\OrderStatusType', + 'substatus' => '\OpenAPI\Client\Model\OrderSubstatusType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'status' => null, + 'substatus' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'status' => false, + 'substatus' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'status' => 'status', + 'substatus' => 'substatus' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'status' => 'setStatus', + 'substatus' => 'setSubstatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'status' => 'getStatus', + 'substatus' => 'getSubstatus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('substatus', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор заказа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OrderStatusType + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OrderStatusType $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets substatus + * + * @return \OpenAPI\Client\Model\OrderSubstatusType|null + */ + public function getSubstatus() + { + return $this->container['substatus']; + } + + /** + * Sets substatus + * + * @param \OpenAPI\Client\Model\OrderSubstatusType|null $substatus substatus + * + * @return self + */ + public function setSubstatus($substatus) + { + if (is_null($substatus)) { + throw new \InvalidArgumentException('non-nullable substatus cannot be null'); + } + $this->container['substatus'] = $substatus; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderStatsStatusType.php b/erp24/lib/yandex_market_api/Model/OrderStatsStatusType.php new file mode 100644 index 00000000..f7897ee6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderStatsStatusType.php @@ -0,0 +1,102 @@ + + */ +class OrderStatusChangeDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderStatusChangeDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\OrderStatusType', + 'substatus' => '\OpenAPI\Client\Model\OrderSubstatusType', + 'delivery' => '\OpenAPI\Client\Model\OrderStatusChangeDeliveryDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'substatus' => null, + 'delivery' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'substatus' => false, + 'delivery' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'substatus' => 'substatus', + 'delivery' => 'delivery' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'substatus' => 'setSubstatus', + 'delivery' => 'setDelivery' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'substatus' => 'getSubstatus', + 'delivery' => 'getDelivery' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('substatus', $data ?? [], null); + $this->setIfExists('delivery', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OrderStatusType + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OrderStatusType $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets substatus + * + * @return \OpenAPI\Client\Model\OrderSubstatusType|null + */ + public function getSubstatus() + { + return $this->container['substatus']; + } + + /** + * Sets substatus + * + * @param \OpenAPI\Client\Model\OrderSubstatusType|null $substatus substatus + * + * @return self + */ + public function setSubstatus($substatus) + { + if (is_null($substatus)) { + throw new \InvalidArgumentException('non-nullable substatus cannot be null'); + } + $this->container['substatus'] = $substatus; + + return $this; + } + + /** + * Gets delivery + * + * @return \OpenAPI\Client\Model\OrderStatusChangeDeliveryDTO|null + */ + public function getDelivery() + { + return $this->container['delivery']; + } + + /** + * Sets delivery + * + * @param \OpenAPI\Client\Model\OrderStatusChangeDeliveryDTO|null $delivery delivery + * + * @return self + */ + public function setDelivery($delivery) + { + if (is_null($delivery)) { + throw new \InvalidArgumentException('non-nullable delivery cannot be null'); + } + $this->container['delivery'] = $delivery; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderStatusChangeDeliveryDTO.php b/erp24/lib/yandex_market_api/Model/OrderStatusChangeDeliveryDTO.php new file mode 100644 index 00000000..5351be9c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderStatusChangeDeliveryDTO.php @@ -0,0 +1,410 @@ + + */ +class OrderStatusChangeDeliveryDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderStatusChangeDeliveryDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'dates' => '\OpenAPI\Client\Model\OrderStatusChangeDeliveryDatesDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'dates' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'dates' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'dates' => 'dates' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'dates' => 'setDates' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'dates' => 'getDates' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('dates', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets dates + * + * @return \OpenAPI\Client\Model\OrderStatusChangeDeliveryDatesDTO|null + */ + public function getDates() + { + return $this->container['dates']; + } + + /** + * Sets dates + * + * @param \OpenAPI\Client\Model\OrderStatusChangeDeliveryDatesDTO|null $dates dates + * + * @return self + */ + public function setDates($dates) + { + if (is_null($dates)) { + throw new \InvalidArgumentException('non-nullable dates cannot be null'); + } + $this->container['dates'] = $dates; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderStatusChangeDeliveryDatesDTO.php b/erp24/lib/yandex_market_api/Model/OrderStatusChangeDeliveryDatesDTO.php new file mode 100644 index 00000000..c3f23042 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderStatusChangeDeliveryDatesDTO.php @@ -0,0 +1,410 @@ + + */ +class OrderStatusChangeDeliveryDatesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderStatusChangeDeliveryDatesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'real_delivery_date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'real_delivery_date' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'real_delivery_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'real_delivery_date' => 'realDeliveryDate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'real_delivery_date' => 'setRealDeliveryDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'real_delivery_date' => 'getRealDeliveryDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('real_delivery_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets real_delivery_date + * + * @return \DateTime|null + */ + public function getRealDeliveryDate() + { + return $this->container['real_delivery_date']; + } + + /** + * Sets real_delivery_date + * + * @param \DateTime|null $real_delivery_date **Только для модели DBS** Фактическая дата доставки.

                                          Когда передавать параметр `realDeliveryDate`: * Не передавайте параметр, если: * переводите заказ в любой статус, кроме `PICKUP` или `DELIVERED`; * меняете статус заказа на `PICKUP` или `DELIVERED` в день доставки — будет указана дата выполнения запроса. * Передавайте дату доставки, если переводите заказ в статус `PICKUP` или `DELIVERED` не в день доставки. Нельзя указывать дату доставки в будущем. {% note warning \"Индекс качества\" %} Передача статуса после установленного срока снижает индекс качества. О сроках читайте [в Справке Маркета для продавцов](https://yandex.ru/support2/marketplace/ru/quality/tech#dbs). {% endnote %}   + * + * @return self + */ + public function setRealDeliveryDate($real_delivery_date) + { + if (is_null($real_delivery_date)) { + throw new \InvalidArgumentException('non-nullable real_delivery_date cannot be null'); + } + $this->container['real_delivery_date'] = $real_delivery_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderStatusType.php b/erp24/lib/yandex_market_api/Model/OrderStatusType.php new file mode 100644 index 00000000..8e29ed65 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderStatusType.php @@ -0,0 +1,93 @@ + + */ +class OrderSubsidyDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderSubsidyDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OrderSubsidyType', + 'amount' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'amount' => 'decimal' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'amount' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'amount' => 'amount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'amount' => 'setAmount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'amount' => 'getAmount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrderSubsidyType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrderSubsidyType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets amount + * + * @return float|null + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param float|null $amount Сумма субсидии. + * + * @return self + */ + public function setAmount($amount) + { + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + $this->container['amount'] = $amount; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderSubsidyType.php b/erp24/lib/yandex_market_api/Model/OrderSubsidyType.php new file mode 100644 index 00000000..262ca0cc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderSubsidyType.php @@ -0,0 +1,66 @@ + + */ +class OrderTrackDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrderTrackDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'track_code' => 'string', + 'delivery_service_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'track_code' => null, + 'delivery_service_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'track_code' => false, + 'delivery_service_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'track_code' => 'trackCode', + 'delivery_service_id' => 'deliveryServiceId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'track_code' => 'setTrackCode', + 'delivery_service_id' => 'setDeliveryServiceId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'track_code' => 'getTrackCode', + 'delivery_service_id' => 'getDeliveryServiceId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('track_code', $data ?? [], null); + $this->setIfExists('delivery_service_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets track_code + * + * @return string|null + */ + public function getTrackCode() + { + return $this->container['track_code']; + } + + /** + * Sets track_code + * + * @param string|null $track_code Трек‑номер посылки. + * + * @return self + */ + public function setTrackCode($track_code) + { + if (is_null($track_code)) { + throw new \InvalidArgumentException('non-nullable track_code cannot be null'); + } + $this->container['track_code'] = $track_code; + + return $this; + } + + /** + * Gets delivery_service_id + * + * @return int|null + */ + public function getDeliveryServiceId() + { + return $this->container['delivery_service_id']; + } + + /** + * Sets delivery_service_id + * + * @param int|null $delivery_service_id Идентификатор службы доставки. Информацию о службе доставки можно получить с помощью запроса [GET delivery/services](../../reference/orders/getDeliveryServices.md). + * + * @return self + */ + public function setDeliveryServiceId($delivery_service_id) + { + if (is_null($delivery_service_id)) { + throw new \InvalidArgumentException('non-nullable delivery_service_id cannot be null'); + } + $this->container['delivery_service_id'] = $delivery_service_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrderUpdateStatusType.php b/erp24/lib/yandex_market_api/Model/OrderUpdateStatusType.php new file mode 100644 index 00000000..c5c40f03 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrderUpdateStatusType.php @@ -0,0 +1,63 @@ + + */ +class OrdersShipmentInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersShipmentInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order_ids_with_labels' => 'int[]', + 'order_ids_without_labels' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order_ids_with_labels' => 'int64', + 'order_ids_without_labels' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order_ids_with_labels' => false, + 'order_ids_without_labels' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order_ids_with_labels' => 'orderIdsWithLabels', + 'order_ids_without_labels' => 'orderIdsWithoutLabels' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order_ids_with_labels' => 'setOrderIdsWithLabels', + 'order_ids_without_labels' => 'setOrderIdsWithoutLabels' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order_ids_with_labels' => 'getOrderIdsWithLabels', + 'order_ids_without_labels' => 'getOrderIdsWithoutLabels' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order_ids_with_labels', $data ?? [], null); + $this->setIfExists('order_ids_without_labels', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['order_ids_with_labels'] === null) { + $invalidProperties[] = "'order_ids_with_labels' can't be null"; + } + if ($this->container['order_ids_without_labels'] === null) { + $invalidProperties[] = "'order_ids_without_labels' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order_ids_with_labels + * + * @return int[] + */ + public function getOrderIdsWithLabels() + { + return $this->container['order_ids_with_labels']; + } + + /** + * Sets order_ids_with_labels + * + * @param int[] $order_ids_with_labels Идентификаторы заказов в отгрузке, для которых можно распечатать ярлыки. + * + * @return self + */ + public function setOrderIdsWithLabels($order_ids_with_labels) + { + if (is_null($order_ids_with_labels)) { + throw new \InvalidArgumentException('non-nullable order_ids_with_labels cannot be null'); + } + + + $this->container['order_ids_with_labels'] = $order_ids_with_labels; + + return $this; + } + + /** + * Gets order_ids_without_labels + * + * @return int[] + */ + public function getOrderIdsWithoutLabels() + { + return $this->container['order_ids_without_labels']; + } + + /** + * Sets order_ids_without_labels + * + * @param int[] $order_ids_without_labels Идентификаторы заказов в отгрузке, для которых нельзя распечатать ярлыки. + * + * @return self + */ + public function setOrderIdsWithoutLabels($order_ids_without_labels) + { + if (is_null($order_ids_without_labels)) { + throw new \InvalidArgumentException('non-nullable order_ids_without_labels cannot be null'); + } + + + $this->container['order_ids_without_labels'] = $order_ids_without_labels; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsCommissionDTO.php b/erp24/lib/yandex_market_api/Model/OrdersStatsCommissionDTO.php new file mode 100644 index 00000000..44096d2b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsCommissionDTO.php @@ -0,0 +1,444 @@ + + */ +class OrdersStatsCommissionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsCommissionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OrdersStatsCommissionType', + 'actual' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'actual' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'actual' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'actual' => 'actual' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'actual' => 'setActual' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'actual' => 'getActual' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('actual', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrdersStatsCommissionType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrdersStatsCommissionType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets actual + * + * @return float|null + */ + public function getActual() + { + return $this->container['actual']; + } + + /** + * Sets actual + * + * @param float|null $actual Сумма в рублях, которая была выставлена в момент создания заказа и которую нужно оплатить. Точность — два знака после запятой. + * + * @return self + */ + public function setActual($actual) + { + if (is_null($actual)) { + throw new \InvalidArgumentException('non-nullable actual cannot be null'); + } + $this->container['actual'] = $actual; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsCommissionType.php b/erp24/lib/yandex_market_api/Model/OrdersStatsCommissionType.php new file mode 100644 index 00000000..62c6b295 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsCommissionType.php @@ -0,0 +1,99 @@ + + */ +class OrdersStatsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'orders' => '\OpenAPI\Client\Model\OrdersStatsOrderDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'orders' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'orders' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'orders' => 'orders', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'orders' => 'setOrders', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'orders' => 'getOrders', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('orders', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['orders'] === null) { + $invalidProperties[] = "'orders' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets orders + * + * @return \OpenAPI\Client\Model\OrdersStatsOrderDTO[] + */ + public function getOrders() + { + return $this->container['orders']; + } + + /** + * Sets orders + * + * @param \OpenAPI\Client\Model\OrdersStatsOrderDTO[] $orders Список заказов. + * + * @return self + */ + public function setOrders($orders) + { + if (is_null($orders)) { + throw new \InvalidArgumentException('non-nullable orders cannot be null'); + } + $this->container['orders'] = $orders; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsDeliveryRegionDTO.php b/erp24/lib/yandex_market_api/Model/OrdersStatsDeliveryRegionDTO.php new file mode 100644 index 00000000..01b7343b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsDeliveryRegionDTO.php @@ -0,0 +1,444 @@ + + */ +class OrdersStatsDeliveryRegionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsDeliveryRegionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор региона доставки. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название региона доставки. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsDetailsDTO.php b/erp24/lib/yandex_market_api/Model/OrdersStatsDetailsDTO.php new file mode 100644 index 00000000..13a53962 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsDetailsDTO.php @@ -0,0 +1,512 @@ + + */ +class OrdersStatsDetailsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsDetailsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'item_status' => '\OpenAPI\Client\Model\OrdersStatsItemStatusType', + 'item_count' => 'int', + 'update_date' => '\DateTime', + 'stock_type' => '\OpenAPI\Client\Model\OrdersStatsStockType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'item_status' => null, + 'item_count' => 'int64', + 'update_date' => 'date', + 'stock_type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'item_status' => false, + 'item_count' => false, + 'update_date' => false, + 'stock_type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'item_status' => 'itemStatus', + 'item_count' => 'itemCount', + 'update_date' => 'updateDate', + 'stock_type' => 'stockType' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'item_status' => 'setItemStatus', + 'item_count' => 'setItemCount', + 'update_date' => 'setUpdateDate', + 'stock_type' => 'setStockType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'item_status' => 'getItemStatus', + 'item_count' => 'getItemCount', + 'update_date' => 'getUpdateDate', + 'stock_type' => 'getStockType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('item_status', $data ?? [], null); + $this->setIfExists('item_count', $data ?? [], null); + $this->setIfExists('update_date', $data ?? [], null); + $this->setIfExists('stock_type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets item_status + * + * @return \OpenAPI\Client\Model\OrdersStatsItemStatusType|null + */ + public function getItemStatus() + { + return $this->container['item_status']; + } + + /** + * Sets item_status + * + * @param \OpenAPI\Client\Model\OrdersStatsItemStatusType|null $item_status item_status + * + * @return self + */ + public function setItemStatus($item_status) + { + if (is_null($item_status)) { + throw new \InvalidArgumentException('non-nullable item_status cannot be null'); + } + $this->container['item_status'] = $item_status; + + return $this; + } + + /** + * Gets item_count + * + * @return int|null + */ + public function getItemCount() + { + return $this->container['item_count']; + } + + /** + * Sets item_count + * + * @param int|null $item_count Количество товара со статусом, указанном в параметре `itemStatus`. + * + * @return self + */ + public function setItemCount($item_count) + { + if (is_null($item_count)) { + throw new \InvalidArgumentException('non-nullable item_count cannot be null'); + } + $this->container['item_count'] = $item_count; + + return $this; + } + + /** + * Gets update_date + * + * @return \DateTime|null + */ + public function getUpdateDate() + { + return $this->container['update_date']; + } + + /** + * Sets update_date + * + * @param \DateTime|null $update_date Дата, когда товар получил статус, указанный в параметре `itemStatus`. Формат даты: `ГГГГ-ММ-ДД`. + * + * @return self + */ + public function setUpdateDate($update_date) + { + if (is_null($update_date)) { + throw new \InvalidArgumentException('non-nullable update_date cannot be null'); + } + $this->container['update_date'] = $update_date; + + return $this; + } + + /** + * Gets stock_type + * + * @return \OpenAPI\Client\Model\OrdersStatsStockType|null + */ + public function getStockType() + { + return $this->container['stock_type']; + } + + /** + * Sets stock_type + * + * @param \OpenAPI\Client\Model\OrdersStatsStockType|null $stock_type stock_type + * + * @return self + */ + public function setStockType($stock_type) + { + if (is_null($stock_type)) { + throw new \InvalidArgumentException('non-nullable stock_type cannot be null'); + } + $this->container['stock_type'] = $stock_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsItemDTO.php b/erp24/lib/yandex_market_api/Model/OrdersStatsItemDTO.php new file mode 100644 index 00000000..ea939219 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsItemDTO.php @@ -0,0 +1,852 @@ + + */ +class OrdersStatsItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_name' => 'string', + 'market_sku' => 'int', + 'shop_sku' => 'string', + 'count' => 'int', + 'prices' => '\OpenAPI\Client\Model\OrdersStatsPriceDTO[]', + 'warehouse' => '\OpenAPI\Client\Model\OrdersStatsWarehouseDTO', + 'details' => '\OpenAPI\Client\Model\OrdersStatsDetailsDTO[]', + 'cis_list' => 'string[]', + 'initial_count' => 'int', + 'bid_fee' => 'int', + 'cofinance_threshold' => 'float', + 'cofinance_value' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_name' => null, + 'market_sku' => 'int64', + 'shop_sku' => null, + 'count' => 'int32', + 'prices' => null, + 'warehouse' => null, + 'details' => null, + 'cis_list' => null, + 'initial_count' => 'int32', + 'bid_fee' => 'int32', + 'cofinance_threshold' => null, + 'cofinance_value' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_name' => false, + 'market_sku' => false, + 'shop_sku' => false, + 'count' => false, + 'prices' => true, + 'warehouse' => false, + 'details' => true, + 'cis_list' => true, + 'initial_count' => false, + 'bid_fee' => false, + 'cofinance_threshold' => false, + 'cofinance_value' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_name' => 'offerName', + 'market_sku' => 'marketSku', + 'shop_sku' => 'shopSku', + 'count' => 'count', + 'prices' => 'prices', + 'warehouse' => 'warehouse', + 'details' => 'details', + 'cis_list' => 'cisList', + 'initial_count' => 'initialCount', + 'bid_fee' => 'bidFee', + 'cofinance_threshold' => 'cofinanceThreshold', + 'cofinance_value' => 'cofinanceValue' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_name' => 'setOfferName', + 'market_sku' => 'setMarketSku', + 'shop_sku' => 'setShopSku', + 'count' => 'setCount', + 'prices' => 'setPrices', + 'warehouse' => 'setWarehouse', + 'details' => 'setDetails', + 'cis_list' => 'setCisList', + 'initial_count' => 'setInitialCount', + 'bid_fee' => 'setBidFee', + 'cofinance_threshold' => 'setCofinanceThreshold', + 'cofinance_value' => 'setCofinanceValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_name' => 'getOfferName', + 'market_sku' => 'getMarketSku', + 'shop_sku' => 'getShopSku', + 'count' => 'getCount', + 'prices' => 'getPrices', + 'warehouse' => 'getWarehouse', + 'details' => 'getDetails', + 'cis_list' => 'getCisList', + 'initial_count' => 'getInitialCount', + 'bid_fee' => 'getBidFee', + 'cofinance_threshold' => 'getCofinanceThreshold', + 'cofinance_value' => 'getCofinanceValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_name', $data ?? [], null); + $this->setIfExists('market_sku', $data ?? [], null); + $this->setIfExists('shop_sku', $data ?? [], null); + $this->setIfExists('count', $data ?? [], null); + $this->setIfExists('prices', $data ?? [], null); + $this->setIfExists('warehouse', $data ?? [], null); + $this->setIfExists('details', $data ?? [], null); + $this->setIfExists('cis_list', $data ?? [], null); + $this->setIfExists('initial_count', $data ?? [], null); + $this->setIfExists('bid_fee', $data ?? [], null); + $this->setIfExists('cofinance_threshold', $data ?? [], null); + $this->setIfExists('cofinance_value', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['bid_fee']) && ($this->container['bid_fee'] > 10000)) { + $invalidProperties[] = "invalid value for 'bid_fee', must be smaller than or equal to 10000."; + } + + if (!is_null($this->container['bid_fee']) && ($this->container['bid_fee'] < 0)) { + $invalidProperties[] = "invalid value for 'bid_fee', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_name + * + * @return string|null + */ + public function getOfferName() + { + return $this->container['offer_name']; + } + + /** + * Sets offer_name + * + * @param string|null $offer_name Название товара. + * + * @return self + */ + public function setOfferName($offer_name) + { + if (is_null($offer_name)) { + throw new \InvalidArgumentException('non-nullable offer_name cannot be null'); + } + $this->container['offer_name'] = $offer_name; + + return $this; + } + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling OrdersStatsItemDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + + /** + * Gets shop_sku + * + * @return string|null + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string|null $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling OrdersStatsItemDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling OrdersStatsItemDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling OrdersStatsItemDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + + /** + * Gets count + * + * @return int|null + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param int|null $count Количество единиц товара с учетом удаленных единиц. Если из заказа удалены все единицы товара, он попадет только в список `initialItems`. + * + * @return self + */ + public function setCount($count) + { + if (is_null($count)) { + throw new \InvalidArgumentException('non-nullable count cannot be null'); + } + $this->container['count'] = $count; + + return $this; + } + + /** + * Gets prices + * + * @return \OpenAPI\Client\Model\OrdersStatsPriceDTO[]|null + */ + public function getPrices() + { + return $this->container['prices']; + } + + /** + * Sets prices + * + * @param \OpenAPI\Client\Model\OrdersStatsPriceDTO[]|null $prices Цена или скидки на товар. + * + * @return self + */ + public function setPrices($prices) + { + if (is_null($prices)) { + array_push($this->openAPINullablesSetToNull, 'prices'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('prices', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['prices'] = $prices; + + return $this; + } + + /** + * Gets warehouse + * + * @return \OpenAPI\Client\Model\OrdersStatsWarehouseDTO|null + */ + public function getWarehouse() + { + return $this->container['warehouse']; + } + + /** + * Sets warehouse + * + * @param \OpenAPI\Client\Model\OrdersStatsWarehouseDTO|null $warehouse warehouse + * + * @return self + */ + public function setWarehouse($warehouse) + { + if (is_null($warehouse)) { + throw new \InvalidArgumentException('non-nullable warehouse cannot be null'); + } + $this->container['warehouse'] = $warehouse; + + return $this; + } + + /** + * Gets details + * + * @return \OpenAPI\Client\Model\OrdersStatsDetailsDTO[]|null + */ + public function getDetails() + { + return $this->container['details']; + } + + /** + * Sets details + * + * @param \OpenAPI\Client\Model\OrdersStatsDetailsDTO[]|null $details Информация об удалении товара из заказа. + * + * @return self + */ + public function setDetails($details) + { + if (is_null($details)) { + array_push($this->openAPINullablesSetToNull, 'details'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('details', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['details'] = $details; + + return $this; + } + + /** + * Gets cis_list + * + * @return string[]|null + */ + public function getCisList() + { + return $this->container['cis_list']; + } + + /** + * Sets cis_list + * + * @param string[]|null $cis_list Список кодов идентификации товара [в системе «Честный ЗНАК»](https://честныйзнак.рф/). + * + * @return self + */ + public function setCisList($cis_list) + { + if (is_null($cis_list)) { + array_push($this->openAPINullablesSetToNull, 'cis_list'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('cis_list', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['cis_list'] = $cis_list; + + return $this; + } + + /** + * Gets initial_count + * + * @return int|null + */ + public function getInitialCount() + { + return $this->container['initial_count']; + } + + /** + * Sets initial_count + * + * @param int|null $initial_count Первоначальное количество единиц товара. + * + * @return self + */ + public function setInitialCount($initial_count) + { + if (is_null($initial_count)) { + throw new \InvalidArgumentException('non-nullable initial_count cannot be null'); + } + $this->container['initial_count'] = $initial_count; + + return $this; + } + + /** + * Gets bid_fee + * + * @return int|null + */ + public function getBidFee() + { + return $this->container['bid_fee']; + } + + /** + * Sets bid_fee + * + * @param int|null $bid_fee Списанная ставка ближайшего конкурента. Указывается в процентах от стоимости товара и умножается на 100. Например, ставка 5% обозначается как 500. + * + * @return self + */ + public function setBidFee($bid_fee) + { + if (is_null($bid_fee)) { + throw new \InvalidArgumentException('non-nullable bid_fee cannot be null'); + } + + if (($bid_fee > 10000)) { + throw new \InvalidArgumentException('invalid value for $bid_fee when calling OrdersStatsItemDTO., must be smaller than or equal to 10000.'); + } + if (($bid_fee < 0)) { + throw new \InvalidArgumentException('invalid value for $bid_fee when calling OrdersStatsItemDTO., must be bigger than or equal to 0.'); + } + + $this->container['bid_fee'] = $bid_fee; + + return $this; + } + + /** + * Gets cofinance_threshold + * + * @return float|null + */ + public function getCofinanceThreshold() + { + return $this->container['cofinance_threshold']; + } + + /** + * Sets cofinance_threshold + * + * @param float|null $cofinance_threshold Порог для скидок с Маркетом на момент оформления заказа. [Что это такое?](https://yandex.ru/support/marketplace/marketing/smart-pricing.html#sponsored-discounts) Указан в рублях. Точность — два знака после запятой. + * + * @return self + */ + public function setCofinanceThreshold($cofinance_threshold) + { + if (is_null($cofinance_threshold)) { + throw new \InvalidArgumentException('non-nullable cofinance_threshold cannot be null'); + } + $this->container['cofinance_threshold'] = $cofinance_threshold; + + return $this; + } + + /** + * Gets cofinance_value + * + * @return float|null + */ + public function getCofinanceValue() + { + return $this->container['cofinance_value']; + } + + /** + * Sets cofinance_value + * + * @param float|null $cofinance_value Скидка с Маркетом. [Что это такое?](https://yandex.ru/support/marketplace/marketing/smart-pricing.html#sponsored-discounts) Указана в рублях. Точность — два знака после запятой. + * + * @return self + */ + public function setCofinanceValue($cofinance_value) + { + if (is_null($cofinance_value)) { + throw new \InvalidArgumentException('non-nullable cofinance_value cannot be null'); + } + $this->container['cofinance_value'] = $cofinance_value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsItemStatusType.php b/erp24/lib/yandex_market_api/Model/OrdersStatsItemStatusType.php new file mode 100644 index 00000000..01ff17e6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsItemStatusType.php @@ -0,0 +1,63 @@ + + */ +class OrdersStatsOrderDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsOrderDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'creation_date' => '\DateTime', + 'status_update_date' => '\DateTime', + 'status' => '\OpenAPI\Client\Model\OrderStatsStatusType', + 'partner_order_id' => 'string', + 'payment_type' => '\OpenAPI\Client\Model\OrdersStatsOrderPaymentType', + 'fake' => 'bool', + 'delivery_region' => '\OpenAPI\Client\Model\OrdersStatsDeliveryRegionDTO', + 'items' => '\OpenAPI\Client\Model\OrdersStatsItemDTO[]', + 'initial_items' => '\OpenAPI\Client\Model\OrdersStatsItemDTO[]', + 'payments' => '\OpenAPI\Client\Model\OrdersStatsPaymentDTO[]', + 'commissions' => '\OpenAPI\Client\Model\OrdersStatsCommissionDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'creation_date' => 'date', + 'status_update_date' => 'date-time', + 'status' => null, + 'partner_order_id' => null, + 'payment_type' => null, + 'fake' => null, + 'delivery_region' => null, + 'items' => null, + 'initial_items' => null, + 'payments' => null, + 'commissions' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'creation_date' => false, + 'status_update_date' => false, + 'status' => false, + 'partner_order_id' => false, + 'payment_type' => false, + 'fake' => false, + 'delivery_region' => false, + 'items' => false, + 'initial_items' => true, + 'payments' => false, + 'commissions' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'creation_date' => 'creationDate', + 'status_update_date' => 'statusUpdateDate', + 'status' => 'status', + 'partner_order_id' => 'partnerOrderId', + 'payment_type' => 'paymentType', + 'fake' => 'fake', + 'delivery_region' => 'deliveryRegion', + 'items' => 'items', + 'initial_items' => 'initialItems', + 'payments' => 'payments', + 'commissions' => 'commissions' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'creation_date' => 'setCreationDate', + 'status_update_date' => 'setStatusUpdateDate', + 'status' => 'setStatus', + 'partner_order_id' => 'setPartnerOrderId', + 'payment_type' => 'setPaymentType', + 'fake' => 'setFake', + 'delivery_region' => 'setDeliveryRegion', + 'items' => 'setItems', + 'initial_items' => 'setInitialItems', + 'payments' => 'setPayments', + 'commissions' => 'setCommissions' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'creation_date' => 'getCreationDate', + 'status_update_date' => 'getStatusUpdateDate', + 'status' => 'getStatus', + 'partner_order_id' => 'getPartnerOrderId', + 'payment_type' => 'getPaymentType', + 'fake' => 'getFake', + 'delivery_region' => 'getDeliveryRegion', + 'items' => 'getItems', + 'initial_items' => 'getInitialItems', + 'payments' => 'getPayments', + 'commissions' => 'getCommissions' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('creation_date', $data ?? [], null); + $this->setIfExists('status_update_date', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('partner_order_id', $data ?? [], null); + $this->setIfExists('payment_type', $data ?? [], null); + $this->setIfExists('fake', $data ?? [], null); + $this->setIfExists('delivery_region', $data ?? [], null); + $this->setIfExists('items', $data ?? [], null); + $this->setIfExists('initial_items', $data ?? [], null); + $this->setIfExists('payments', $data ?? [], null); + $this->setIfExists('commissions', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + if ($this->container['payments'] === null) { + $invalidProperties[] = "'payments' can't be null"; + } + if ($this->container['commissions'] === null) { + $invalidProperties[] = "'commissions' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор заказа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets creation_date + * + * @return \DateTime|null + */ + public function getCreationDate() + { + return $this->container['creation_date']; + } + + /** + * Sets creation_date + * + * @param \DateTime|null $creation_date Дата создания заказа. Формат даты: `ГГГГ-ММ-ДД`. + * + * @return self + */ + public function setCreationDate($creation_date) + { + if (is_null($creation_date)) { + throw new \InvalidArgumentException('non-nullable creation_date cannot be null'); + } + $this->container['creation_date'] = $creation_date; + + return $this; + } + + /** + * Gets status_update_date + * + * @return \DateTime|null + */ + public function getStatusUpdateDate() + { + return $this->container['status_update_date']; + } + + /** + * Sets status_update_date + * + * @param \DateTime|null $status_update_date Дата и время, когда статус заказа был изменен в последний раз. Формат даты и времени: ISO 8601. Например, `2017-11-21T00:00:00`. Часовой пояс — UTC+03:00 (Москва). + * + * @return self + */ + public function setStatusUpdateDate($status_update_date) + { + if (is_null($status_update_date)) { + throw new \InvalidArgumentException('non-nullable status_update_date cannot be null'); + } + $this->container['status_update_date'] = $status_update_date; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OrderStatsStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OrderStatsStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets partner_order_id + * + * @return string|null + */ + public function getPartnerOrderId() + { + return $this->container['partner_order_id']; + } + + /** + * Sets partner_order_id + * + * @param string|null $partner_order_id Идентификатор заказа в информационной системе магазина. + * + * @return self + */ + public function setPartnerOrderId($partner_order_id) + { + if (is_null($partner_order_id)) { + throw new \InvalidArgumentException('non-nullable partner_order_id cannot be null'); + } + $this->container['partner_order_id'] = $partner_order_id; + + return $this; + } + + /** + * Gets payment_type + * + * @return \OpenAPI\Client\Model\OrdersStatsOrderPaymentType|null + */ + public function getPaymentType() + { + return $this->container['payment_type']; + } + + /** + * Sets payment_type + * + * @param \OpenAPI\Client\Model\OrdersStatsOrderPaymentType|null $payment_type payment_type + * + * @return self + */ + public function setPaymentType($payment_type) + { + if (is_null($payment_type)) { + throw new \InvalidArgumentException('non-nullable payment_type cannot be null'); + } + $this->container['payment_type'] = $payment_type; + + return $this; + } + + /** + * Gets fake + * + * @return bool|null + */ + public function getFake() + { + return $this->container['fake']; + } + + /** + * Sets fake + * + * @param bool|null $fake Тип заказа: * `false` — настоящий заказ покупателя. * `true` — [тестовый](../../pushapi/concepts/sandbox.md) заказ Маркета. + * + * @return self + */ + public function setFake($fake) + { + if (is_null($fake)) { + throw new \InvalidArgumentException('non-nullable fake cannot be null'); + } + $this->container['fake'] = $fake; + + return $this; + } + + /** + * Gets delivery_region + * + * @return \OpenAPI\Client\Model\OrdersStatsDeliveryRegionDTO|null + */ + public function getDeliveryRegion() + { + return $this->container['delivery_region']; + } + + /** + * Sets delivery_region + * + * @param \OpenAPI\Client\Model\OrdersStatsDeliveryRegionDTO|null $delivery_region delivery_region + * + * @return self + */ + public function setDeliveryRegion($delivery_region) + { + if (is_null($delivery_region)) { + throw new \InvalidArgumentException('non-nullable delivery_region cannot be null'); + } + $this->container['delivery_region'] = $delivery_region; + + return $this; + } + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\OrdersStatsItemDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\OrdersStatsItemDTO[] $items Список товаров в заказе после возможных изменений. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets initial_items + * + * @return \OpenAPI\Client\Model\OrdersStatsItemDTO[]|null + */ + public function getInitialItems() + { + return $this->container['initial_items']; + } + + /** + * Sets initial_items + * + * @param \OpenAPI\Client\Model\OrdersStatsItemDTO[]|null $initial_items Список товаров в заказе до изменений. + * + * @return self + */ + public function setInitialItems($initial_items) + { + if (is_null($initial_items)) { + array_push($this->openAPINullablesSetToNull, 'initial_items'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('initial_items', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['initial_items'] = $initial_items; + + return $this; + } + + /** + * Gets payments + * + * @return \OpenAPI\Client\Model\OrdersStatsPaymentDTO[] + */ + public function getPayments() + { + return $this->container['payments']; + } + + /** + * Sets payments + * + * @param \OpenAPI\Client\Model\OrdersStatsPaymentDTO[] $payments Информация о денежных переводах по заказу. + * + * @return self + */ + public function setPayments($payments) + { + if (is_null($payments)) { + throw new \InvalidArgumentException('non-nullable payments cannot be null'); + } + $this->container['payments'] = $payments; + + return $this; + } + + /** + * Gets commissions + * + * @return \OpenAPI\Client\Model\OrdersStatsCommissionDTO[] + */ + public function getCommissions() + { + return $this->container['commissions']; + } + + /** + * Sets commissions + * + * @param \OpenAPI\Client\Model\OrdersStatsCommissionDTO[] $commissions Информация о комиссиях за заказ. + * + * @return self + */ + public function setCommissions($commissions) + { + if (is_null($commissions)) { + throw new \InvalidArgumentException('non-nullable commissions cannot be null'); + } + $this->container['commissions'] = $commissions; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsOrderPaymentType.php b/erp24/lib/yandex_market_api/Model/OrdersStatsOrderPaymentType.php new file mode 100644 index 00000000..2c50e24c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsOrderPaymentType.php @@ -0,0 +1,69 @@ + + */ +class OrdersStatsPaymentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsPaymentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'date' => '\DateTime', + 'type' => '\OpenAPI\Client\Model\OrdersStatsPaymentType', + 'source' => '\OpenAPI\Client\Model\OrdersStatsPaymentSourceType', + 'total' => 'float', + 'payment_order' => '\OpenAPI\Client\Model\OrdersStatsPaymentOrderDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'date' => 'date', + 'type' => null, + 'source' => null, + 'total' => null, + 'payment_order' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'date' => false, + 'type' => false, + 'source' => false, + 'total' => false, + 'payment_order' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'date' => 'date', + 'type' => 'type', + 'source' => 'source', + 'total' => 'total', + 'payment_order' => 'paymentOrder' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'date' => 'setDate', + 'type' => 'setType', + 'source' => 'setSource', + 'total' => 'setTotal', + 'payment_order' => 'setPaymentOrder' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'date' => 'getDate', + 'type' => 'getType', + 'source' => 'getSource', + 'total' => 'getTotal', + 'payment_order' => 'getPaymentOrder' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('date', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('source', $data ?? [], null); + $this->setIfExists('total', $data ?? [], null); + $this->setIfExists('payment_order', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Идентификатор денежного перевода. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets date + * + * @return \DateTime|null + */ + public function getDate() + { + return $this->container['date']; + } + + /** + * Sets date + * + * @param \DateTime|null $date Дата денежного перевода. Формат даты: `ГГГГ-ММ-ДД`. + * + * @return self + */ + public function setDate($date) + { + if (is_null($date)) { + throw new \InvalidArgumentException('non-nullable date cannot be null'); + } + $this->container['date'] = $date; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrdersStatsPaymentType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrdersStatsPaymentType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets source + * + * @return \OpenAPI\Client\Model\OrdersStatsPaymentSourceType|null + */ + public function getSource() + { + return $this->container['source']; + } + + /** + * Sets source + * + * @param \OpenAPI\Client\Model\OrdersStatsPaymentSourceType|null $source source + * + * @return self + */ + public function setSource($source) + { + if (is_null($source)) { + throw new \InvalidArgumentException('non-nullable source cannot be null'); + } + $this->container['source'] = $source; + + return $this; + } + + /** + * Gets total + * + * @return float|null + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float|null $total Сумма денежного перевода. Значение указывается в рублях независимо от способа денежного перевода. Точность — два знака после запятой. + * + * @return self + */ + public function setTotal($total) + { + if (is_null($total)) { + throw new \InvalidArgumentException('non-nullable total cannot be null'); + } + $this->container['total'] = $total; + + return $this; + } + + /** + * Gets payment_order + * + * @return \OpenAPI\Client\Model\OrdersStatsPaymentOrderDTO|null + */ + public function getPaymentOrder() + { + return $this->container['payment_order']; + } + + /** + * Sets payment_order + * + * @param \OpenAPI\Client\Model\OrdersStatsPaymentOrderDTO|null $payment_order payment_order + * + * @return self + */ + public function setPaymentOrder($payment_order) + { + if (is_null($payment_order)) { + throw new \InvalidArgumentException('non-nullable payment_order cannot be null'); + } + $this->container['payment_order'] = $payment_order; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsPaymentOrderDTO.php b/erp24/lib/yandex_market_api/Model/OrdersStatsPaymentOrderDTO.php new file mode 100644 index 00000000..195b5f71 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsPaymentOrderDTO.php @@ -0,0 +1,444 @@ + + */ +class OrdersStatsPaymentOrderDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsPaymentOrderDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'string', + 'date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => null, + 'date' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'date' => 'date' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'date' => 'setDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'date' => 'getDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Номер платежного поручения. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets date + * + * @return \DateTime|null + */ + public function getDate() + { + return $this->container['date']; + } + + /** + * Sets date + * + * @param \DateTime|null $date Дата платежного поручения. Формат даты: `ГГГГ‑ММ‑ДД`. + * + * @return self + */ + public function setDate($date) + { + if (is_null($date)) { + throw new \InvalidArgumentException('non-nullable date cannot be null'); + } + $this->container['date'] = $date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsPaymentSourceType.php b/erp24/lib/yandex_market_api/Model/OrdersStatsPaymentSourceType.php new file mode 100644 index 00000000..4fd9774e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsPaymentSourceType.php @@ -0,0 +1,69 @@ + + */ +class OrdersStatsPriceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsPriceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\OrdersStatsPriceType', + 'cost_per_item' => 'float', + 'total' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'cost_per_item' => null, + 'total' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'cost_per_item' => false, + 'total' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'cost_per_item' => 'costPerItem', + 'total' => 'total' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'cost_per_item' => 'setCostPerItem', + 'total' => 'setTotal' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'cost_per_item' => 'getCostPerItem', + 'total' => 'getTotal' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('cost_per_item', $data ?? [], null); + $this->setIfExists('total', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OrdersStatsPriceType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OrdersStatsPriceType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets cost_per_item + * + * @return float|null + */ + public function getCostPerItem() + { + return $this->container['cost_per_item']; + } + + /** + * Sets cost_per_item + * + * @param float|null $cost_per_item Цена или скидка на единицу товара в заказе. Указана в рублях. Точность — два знака после запятой. + * + * @return self + */ + public function setCostPerItem($cost_per_item) + { + if (is_null($cost_per_item)) { + throw new \InvalidArgumentException('non-nullable cost_per_item cannot be null'); + } + $this->container['cost_per_item'] = $cost_per_item; + + return $this; + } + + /** + * Gets total + * + * @return float|null + */ + public function getTotal() + { + return $this->container['total']; + } + + /** + * Sets total + * + * @param float|null $total Суммарная цена или скидка на все единицы товара в заказе. Указана в рублях. Точность — два знака после запятой. + * + * @return self + */ + public function setTotal($total) + { + if (is_null($total)) { + throw new \InvalidArgumentException('non-nullable total cannot be null'); + } + $this->container['total'] = $total; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OrdersStatsPriceType.php b/erp24/lib/yandex_market_api/Model/OrdersStatsPriceType.php new file mode 100644 index 00000000..a4e12d2e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OrdersStatsPriceType.php @@ -0,0 +1,66 @@ + + */ +class OrdersStatsWarehouseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OrdersStatsWarehouseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор склада. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Название склада. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OutletAddressDTO.php b/erp24/lib/yandex_market_api/Model/OutletAddressDTO.php new file mode 100644 index 00000000..0d90d3ae --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OutletAddressDTO.php @@ -0,0 +1,733 @@ + + */ +class OutletAddressDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OutletAddressDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'region_id' => 'int', + 'street' => 'string', + 'number' => 'string', + 'building' => 'string', + 'estate' => 'string', + 'block' => 'string', + 'additional' => 'string', + 'km' => 'int', + 'city' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'region_id' => 'int64', + 'street' => null, + 'number' => null, + 'building' => null, + 'estate' => null, + 'block' => null, + 'additional' => null, + 'km' => 'int32', + 'city' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'region_id' => false, + 'street' => false, + 'number' => false, + 'building' => false, + 'estate' => false, + 'block' => false, + 'additional' => false, + 'km' => false, + 'city' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'region_id' => 'regionId', + 'street' => 'street', + 'number' => 'number', + 'building' => 'building', + 'estate' => 'estate', + 'block' => 'block', + 'additional' => 'additional', + 'km' => 'km', + 'city' => 'city' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'region_id' => 'setRegionId', + 'street' => 'setStreet', + 'number' => 'setNumber', + 'building' => 'setBuilding', + 'estate' => 'setEstate', + 'block' => 'setBlock', + 'additional' => 'setAdditional', + 'km' => 'setKm', + 'city' => 'setCity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'region_id' => 'getRegionId', + 'street' => 'getStreet', + 'number' => 'getNumber', + 'building' => 'getBuilding', + 'estate' => 'getEstate', + 'block' => 'getBlock', + 'additional' => 'getAdditional', + 'km' => 'getKm', + 'city' => 'getCity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('region_id', $data ?? [], null); + $this->setIfExists('street', $data ?? [], null); + $this->setIfExists('number', $data ?? [], null); + $this->setIfExists('building', $data ?? [], null); + $this->setIfExists('estate', $data ?? [], null); + $this->setIfExists('block', $data ?? [], null); + $this->setIfExists('additional', $data ?? [], null); + $this->setIfExists('km', $data ?? [], null); + $this->setIfExists('city', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['region_id'] === null) { + $invalidProperties[] = "'region_id' can't be null"; + } + if (!is_null($this->container['street']) && (mb_strlen($this->container['street']) > 512)) { + $invalidProperties[] = "invalid value for 'street', the character length must be smaller than or equal to 512."; + } + + if (!is_null($this->container['number']) && (mb_strlen($this->container['number']) > 256)) { + $invalidProperties[] = "invalid value for 'number', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['building']) && (mb_strlen($this->container['building']) > 16)) { + $invalidProperties[] = "invalid value for 'building', the character length must be smaller than or equal to 16."; + } + + if (!is_null($this->container['estate']) && (mb_strlen($this->container['estate']) > 16)) { + $invalidProperties[] = "invalid value for 'estate', the character length must be smaller than or equal to 16."; + } + + if (!is_null($this->container['block']) && (mb_strlen($this->container['block']) > 16)) { + $invalidProperties[] = "invalid value for 'block', the character length must be smaller than or equal to 16."; + } + + if (!is_null($this->container['city']) && (mb_strlen($this->container['city']) > 200)) { + $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 200."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets region_id + * + * @return int + */ + public function getRegionId() + { + return $this->container['region_id']; + } + + /** + * Sets region_id + * + * @param int $region_id Идентификатор региона. Идентификатор можно получить c помощью запроса [GET regions](../../reference/regions/searchRegionsByName.md). {% note alert %} При создании и редактировании точек продаж можно указывать только регионы типов `TOWN` (город), `CITY` (крупный город) и `REPUBLIC_AREA` (район субъекта федерации). Тип региона указан в выходных параметрах type запросов [GET regions](../../reference/regions/searchRegionsByName.md) и [GET regions/{regionId}](../../reference/regions/searchRegionsById.md). {% endnote %} + * + * @return self + */ + public function setRegionId($region_id) + { + if (is_null($region_id)) { + throw new \InvalidArgumentException('non-nullable region_id cannot be null'); + } + $this->container['region_id'] = $region_id; + + return $this; + } + + /** + * Gets street + * + * @return string|null + */ + public function getStreet() + { + return $this->container['street']; + } + + /** + * Sets street + * + * @param string|null $street Улица. + * + * @return self + */ + public function setStreet($street) + { + if (is_null($street)) { + throw new \InvalidArgumentException('non-nullable street cannot be null'); + } + if ((mb_strlen($street) > 512)) { + throw new \InvalidArgumentException('invalid length for $street when calling OutletAddressDTO., must be smaller than or equal to 512.'); + } + + $this->container['street'] = $street; + + return $this; + } + + /** + * Gets number + * + * @return string|null + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param string|null $number Номер дома. + * + * @return self + */ + public function setNumber($number) + { + if (is_null($number)) { + throw new \InvalidArgumentException('non-nullable number cannot be null'); + } + if ((mb_strlen($number) > 256)) { + throw new \InvalidArgumentException('invalid length for $number when calling OutletAddressDTO., must be smaller than or equal to 256.'); + } + + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets building + * + * @return string|null + */ + public function getBuilding() + { + return $this->container['building']; + } + + /** + * Sets building + * + * @param string|null $building Номер строения. + * + * @return self + */ + public function setBuilding($building) + { + if (is_null($building)) { + throw new \InvalidArgumentException('non-nullable building cannot be null'); + } + if ((mb_strlen($building) > 16)) { + throw new \InvalidArgumentException('invalid length for $building when calling OutletAddressDTO., must be smaller than or equal to 16.'); + } + + $this->container['building'] = $building; + + return $this; + } + + /** + * Gets estate + * + * @return string|null + */ + public function getEstate() + { + return $this->container['estate']; + } + + /** + * Sets estate + * + * @param string|null $estate Номер владения. + * + * @return self + */ + public function setEstate($estate) + { + if (is_null($estate)) { + throw new \InvalidArgumentException('non-nullable estate cannot be null'); + } + if ((mb_strlen($estate) > 16)) { + throw new \InvalidArgumentException('invalid length for $estate when calling OutletAddressDTO., must be smaller than or equal to 16.'); + } + + $this->container['estate'] = $estate; + + return $this; + } + + /** + * Gets block + * + * @return string|null + */ + public function getBlock() + { + return $this->container['block']; + } + + /** + * Sets block + * + * @param string|null $block Номер корпуса. + * + * @return self + */ + public function setBlock($block) + { + if (is_null($block)) { + throw new \InvalidArgumentException('non-nullable block cannot be null'); + } + if ((mb_strlen($block) > 16)) { + throw new \InvalidArgumentException('invalid length for $block when calling OutletAddressDTO., must be smaller than or equal to 16.'); + } + + $this->container['block'] = $block; + + return $this; + } + + /** + * Gets additional + * + * @return string|null + */ + public function getAdditional() + { + return $this->container['additional']; + } + + /** + * Sets additional + * + * @param string|null $additional Дополнительная информация. + * + * @return self + */ + public function setAdditional($additional) + { + if (is_null($additional)) { + throw new \InvalidArgumentException('non-nullable additional cannot be null'); + } + $this->container['additional'] = $additional; + + return $this; + } + + /** + * Gets km + * + * @return int|null + */ + public function getKm() + { + return $this->container['km']; + } + + /** + * Sets km + * + * @param int|null $km Порядковый номер километра дороги, на котором располагается точка продаж, если отсутствует улица. + * + * @return self + */ + public function setKm($km) + { + if (is_null($km)) { + throw new \InvalidArgumentException('non-nullable km cannot be null'); + } + $this->container['km'] = $km; + + return $this; + } + + /** + * Gets city + * + * @return string|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string|null $city {% note warning \"\" %} Этот параметр устарел. Не используйте его. Город или населенный пункт возвращается в параметре `regionId`. {% endnote %} + * + * @return self + */ + public function setCity($city) + { + if (is_null($city)) { + throw new \InvalidArgumentException('non-nullable city cannot be null'); + } + if ((mb_strlen($city) > 200)) { + throw new \InvalidArgumentException('invalid length for $city when calling OutletAddressDTO., must be smaller than or equal to 200.'); + } + + $this->container['city'] = $city; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OutletDTO.php b/erp24/lib/yandex_market_api/Model/OutletDTO.php new file mode 100644 index 00000000..f1d85f53 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OutletDTO.php @@ -0,0 +1,781 @@ + + */ +class OutletDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OutletDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'type' => '\OpenAPI\Client\Model\OutletType', + 'coords' => 'string', + 'is_main' => 'bool', + 'shop_outlet_code' => 'string', + 'visibility' => '\OpenAPI\Client\Model\OutletVisibilityType', + 'address' => '\OpenAPI\Client\Model\OutletAddressDTO', + 'phones' => 'string[]', + 'working_schedule' => '\OpenAPI\Client\Model\OutletWorkingScheduleDTO', + 'delivery_rules' => '\OpenAPI\Client\Model\OutletDeliveryRuleDTO[]', + 'storage_period' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'type' => null, + 'coords' => null, + 'is_main' => null, + 'shop_outlet_code' => null, + 'visibility' => null, + 'address' => null, + 'phones' => null, + 'working_schedule' => null, + 'delivery_rules' => null, + 'storage_period' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'type' => false, + 'coords' => false, + 'is_main' => false, + 'shop_outlet_code' => false, + 'visibility' => false, + 'address' => false, + 'phones' => false, + 'working_schedule' => false, + 'delivery_rules' => true, + 'storage_period' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'type' => 'type', + 'coords' => 'coords', + 'is_main' => 'isMain', + 'shop_outlet_code' => 'shopOutletCode', + 'visibility' => 'visibility', + 'address' => 'address', + 'phones' => 'phones', + 'working_schedule' => 'workingSchedule', + 'delivery_rules' => 'deliveryRules', + 'storage_period' => 'storagePeriod' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'type' => 'setType', + 'coords' => 'setCoords', + 'is_main' => 'setIsMain', + 'shop_outlet_code' => 'setShopOutletCode', + 'visibility' => 'setVisibility', + 'address' => 'setAddress', + 'phones' => 'setPhones', + 'working_schedule' => 'setWorkingSchedule', + 'delivery_rules' => 'setDeliveryRules', + 'storage_period' => 'setStoragePeriod' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'type' => 'getType', + 'coords' => 'getCoords', + 'is_main' => 'getIsMain', + 'shop_outlet_code' => 'getShopOutletCode', + 'visibility' => 'getVisibility', + 'address' => 'getAddress', + 'phones' => 'getPhones', + 'working_schedule' => 'getWorkingSchedule', + 'delivery_rules' => 'getDeliveryRules', + 'storage_period' => 'getStoragePeriod' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('coords', $data ?? [], null); + $this->setIfExists('is_main', $data ?? [], null); + $this->setIfExists('shop_outlet_code', $data ?? [], null); + $this->setIfExists('visibility', $data ?? [], null); + $this->setIfExists('address', $data ?? [], null); + $this->setIfExists('phones', $data ?? [], null); + $this->setIfExists('working_schedule', $data ?? [], null); + $this->setIfExists('delivery_rules', $data ?? [], null); + $this->setIfExists('storage_period', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['address'] === null) { + $invalidProperties[] = "'address' can't be null"; + } + if ($this->container['phones'] === null) { + $invalidProperties[] = "'phones' can't be null"; + } + if ((count($this->container['phones']) < 1)) { + $invalidProperties[] = "invalid value for 'phones', number of items must be greater than or equal to 1."; + } + + if ($this->container['working_schedule'] === null) { + $invalidProperties[] = "'working_schedule' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название точки продаж. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OutletType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OutletType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets coords + * + * @return string|null + */ + public function getCoords() + { + return $this->container['coords']; + } + + /** + * Sets coords + * + * @param string|null $coords Координаты точки продаж. Формат: долгота, широта. Разделители: запятая и / или пробел. Например, `20.4522144, 54.7104264`. Если параметр не передан, координаты будут определены по значениям параметров, вложенных в `address`. + * + * @return self + */ + public function setCoords($coords) + { + if (is_null($coords)) { + throw new \InvalidArgumentException('non-nullable coords cannot be null'); + } + $this->container['coords'] = $coords; + + return $this; + } + + /** + * Gets is_main + * + * @return bool|null + */ + public function getIsMain() + { + return $this->container['is_main']; + } + + /** + * Sets is_main + * + * @param bool|null $is_main Признак основной точки продаж. Возможные значения: * `false` — неосновная точка продаж. * `true` — основная точка продаж. + * + * @return self + */ + public function setIsMain($is_main) + { + if (is_null($is_main)) { + throw new \InvalidArgumentException('non-nullable is_main cannot be null'); + } + $this->container['is_main'] = $is_main; + + return $this; + } + + /** + * Gets shop_outlet_code + * + * @return string|null + */ + public function getShopOutletCode() + { + return $this->container['shop_outlet_code']; + } + + /** + * Sets shop_outlet_code + * + * @param string|null $shop_outlet_code Идентификатор точки продаж, присвоенный магазином. + * + * @return self + */ + public function setShopOutletCode($shop_outlet_code) + { + if (is_null($shop_outlet_code)) { + throw new \InvalidArgumentException('non-nullable shop_outlet_code cannot be null'); + } + $this->container['shop_outlet_code'] = $shop_outlet_code; + + return $this; + } + + /** + * Gets visibility + * + * @return \OpenAPI\Client\Model\OutletVisibilityType|null + */ + public function getVisibility() + { + return $this->container['visibility']; + } + + /** + * Sets visibility + * + * @param \OpenAPI\Client\Model\OutletVisibilityType|null $visibility visibility + * + * @return self + */ + public function setVisibility($visibility) + { + if (is_null($visibility)) { + throw new \InvalidArgumentException('non-nullable visibility cannot be null'); + } + $this->container['visibility'] = $visibility; + + return $this; + } + + /** + * Gets address + * + * @return \OpenAPI\Client\Model\OutletAddressDTO + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \OpenAPI\Client\Model\OutletAddressDTO $address address + * + * @return self + */ + public function setAddress($address) + { + if (is_null($address)) { + throw new \InvalidArgumentException('non-nullable address cannot be null'); + } + $this->container['address'] = $address; + + return $this; + } + + /** + * Gets phones + * + * @return string[] + */ + public function getPhones() + { + return $this->container['phones']; + } + + /** + * Sets phones + * + * @param string[] $phones Номера телефонов точки продаж. Передавайте в формате: `+7 (999) 999-99-99`. + * + * @return self + */ + public function setPhones($phones) + { + if (is_null($phones)) { + throw new \InvalidArgumentException('non-nullable phones cannot be null'); + } + + + if ((count($phones) < 1)) { + throw new \InvalidArgumentException('invalid length for $phones when calling OutletDTO., number of items must be greater than or equal to 1.'); + } + $this->container['phones'] = $phones; + + return $this; + } + + /** + * Gets working_schedule + * + * @return \OpenAPI\Client\Model\OutletWorkingScheduleDTO + */ + public function getWorkingSchedule() + { + return $this->container['working_schedule']; + } + + /** + * Sets working_schedule + * + * @param \OpenAPI\Client\Model\OutletWorkingScheduleDTO $working_schedule working_schedule + * + * @return self + */ + public function setWorkingSchedule($working_schedule) + { + if (is_null($working_schedule)) { + throw new \InvalidArgumentException('non-nullable working_schedule cannot be null'); + } + $this->container['working_schedule'] = $working_schedule; + + return $this; + } + + /** + * Gets delivery_rules + * + * @return \OpenAPI\Client\Model\OutletDeliveryRuleDTO[]|null + */ + public function getDeliveryRules() + { + return $this->container['delivery_rules']; + } + + /** + * Sets delivery_rules + * + * @param \OpenAPI\Client\Model\OutletDeliveryRuleDTO[]|null $delivery_rules Информация об условиях доставки для данной точки продаж. Обязательный параметр, если параметр `type=DEPOT` или `type=MIXED`. + * + * @return self + */ + public function setDeliveryRules($delivery_rules) + { + if (is_null($delivery_rules)) { + array_push($this->openAPINullablesSetToNull, 'delivery_rules'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('delivery_rules', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['delivery_rules'] = $delivery_rules; + + return $this; + } + + /** + * Gets storage_period + * + * @return int|null + */ + public function getStoragePeriod() + { + return $this->container['storage_period']; + } + + /** + * Sets storage_period + * + * @param int|null $storage_period Срок хранения заказа в собственном пункте выдачи заказов. Считается в днях. + * + * @return self + */ + public function setStoragePeriod($storage_period) + { + if (is_null($storage_period)) { + throw new \InvalidArgumentException('non-nullable storage_period cannot be null'); + } + $this->container['storage_period'] = $storage_period; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OutletDeliveryRuleDTO.php b/erp24/lib/yandex_market_api/Model/OutletDeliveryRuleDTO.php new file mode 100644 index 00000000..d1e99880 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OutletDeliveryRuleDTO.php @@ -0,0 +1,628 @@ + + */ +class OutletDeliveryRuleDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OutletDeliveryRuleDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'min_delivery_days' => 'int', + 'max_delivery_days' => 'int', + 'delivery_service_id' => 'int', + 'order_before' => 'int', + 'price_free_pickup' => 'float', + 'unspecified_delivery_interval' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'min_delivery_days' => 'int32', + 'max_delivery_days' => 'int32', + 'delivery_service_id' => 'int64', + 'order_before' => 'int32', + 'price_free_pickup' => null, + 'unspecified_delivery_interval' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'min_delivery_days' => false, + 'max_delivery_days' => false, + 'delivery_service_id' => false, + 'order_before' => false, + 'price_free_pickup' => false, + 'unspecified_delivery_interval' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'min_delivery_days' => 'minDeliveryDays', + 'max_delivery_days' => 'maxDeliveryDays', + 'delivery_service_id' => 'deliveryServiceId', + 'order_before' => 'orderBefore', + 'price_free_pickup' => 'priceFreePickup', + 'unspecified_delivery_interval' => 'unspecifiedDeliveryInterval' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'min_delivery_days' => 'setMinDeliveryDays', + 'max_delivery_days' => 'setMaxDeliveryDays', + 'delivery_service_id' => 'setDeliveryServiceId', + 'order_before' => 'setOrderBefore', + 'price_free_pickup' => 'setPriceFreePickup', + 'unspecified_delivery_interval' => 'setUnspecifiedDeliveryInterval' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'min_delivery_days' => 'getMinDeliveryDays', + 'max_delivery_days' => 'getMaxDeliveryDays', + 'delivery_service_id' => 'getDeliveryServiceId', + 'order_before' => 'getOrderBefore', + 'price_free_pickup' => 'getPriceFreePickup', + 'unspecified_delivery_interval' => 'getUnspecifiedDeliveryInterval' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('min_delivery_days', $data ?? [], null); + $this->setIfExists('max_delivery_days', $data ?? [], null); + $this->setIfExists('delivery_service_id', $data ?? [], null); + $this->setIfExists('order_before', $data ?? [], null); + $this->setIfExists('price_free_pickup', $data ?? [], null); + $this->setIfExists('unspecified_delivery_interval', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['min_delivery_days']) && ($this->container['min_delivery_days'] > 60)) { + $invalidProperties[] = "invalid value for 'min_delivery_days', must be smaller than or equal to 60."; + } + + if (!is_null($this->container['min_delivery_days']) && ($this->container['min_delivery_days'] < 0)) { + $invalidProperties[] = "invalid value for 'min_delivery_days', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['max_delivery_days']) && ($this->container['max_delivery_days'] > 60)) { + $invalidProperties[] = "invalid value for 'max_delivery_days', must be smaller than or equal to 60."; + } + + if (!is_null($this->container['max_delivery_days']) && ($this->container['max_delivery_days'] < 0)) { + $invalidProperties[] = "invalid value for 'max_delivery_days', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['order_before']) && ($this->container['order_before'] > 24)) { + $invalidProperties[] = "invalid value for 'order_before', must be smaller than or equal to 24."; + } + + if (!is_null($this->container['order_before']) && ($this->container['order_before'] < 0)) { + $invalidProperties[] = "invalid value for 'order_before', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets min_delivery_days + * + * @return int|null + */ + public function getMinDeliveryDays() + { + return $this->container['min_delivery_days']; + } + + /** + * Sets min_delivery_days + * + * @param int|null $min_delivery_days Минимальный срок доставки товаров в точку продаж. Указан в рабочих днях. Минимальное значение: `0` — доставка в день заказа. Максимальное значение: `60`. Допустимые сроки доставки (разница между `minDeliveryDays` и `maxDeliveryDays`) зависят от региона. Для доставки по своему региону разница не должна превышать двух дней. Например, если `minDeliveryDays` равно 1, то для `maxDeliveryDays` допускаются значения от 1 до 3. Для доставки в другие регионы: * Если `minDeliveryDays` до 18 дней, разница не должна превышать четырех дней. Например, если `minDeliveryDays` равно 10, то для `maxDeliveryDays` допускаются значения от 10 до 14. * Если `minDeliveryDays` больше 18 дней, разница должна быть не больше чем в два раза. Например, если `minDeliveryDays` равно 21, то для `maxDeliveryDays` допускаются значения от 21 до 42. Обязательный параметр, если `type=\"DEPOT\"` или `type=\"MIXED\"`. Взаимоисключающий с параметром `unspecifiedDeliveryInterval`. + * + * @return self + */ + public function setMinDeliveryDays($min_delivery_days) + { + if (is_null($min_delivery_days)) { + throw new \InvalidArgumentException('non-nullable min_delivery_days cannot be null'); + } + + if (($min_delivery_days > 60)) { + throw new \InvalidArgumentException('invalid value for $min_delivery_days when calling OutletDeliveryRuleDTO., must be smaller than or equal to 60.'); + } + if (($min_delivery_days < 0)) { + throw new \InvalidArgumentException('invalid value for $min_delivery_days when calling OutletDeliveryRuleDTO., must be bigger than or equal to 0.'); + } + + $this->container['min_delivery_days'] = $min_delivery_days; + + return $this; + } + + /** + * Gets max_delivery_days + * + * @return int|null + */ + public function getMaxDeliveryDays() + { + return $this->container['max_delivery_days']; + } + + /** + * Sets max_delivery_days + * + * @param int|null $max_delivery_days Максимальный срок доставки товаров в точку продаж. Указан в рабочих днях. Минимальное значение: `0` — доставка в день заказа. Максимальное значение: `60`. Допустимые сроки доставки (разница между `minDeliveryDays` и `maxDeliveryDays`) зависят от региона. Для доставки по своему региону разница не должна превышать двух дней. Например, если `minDeliveryDays` равно 1, то для `maxDeliveryDays` допускаются значения от 1 до 3. Для доставки в другие регионы: * Если `minDeliveryDays` до 18 дней, разница не должна превышать четырех дней. Например, если `minDeliveryDays` равно 10, то для `maxDeliveryDays` допускаются значения от 10 до 14. * Если `minDeliveryDays` больше 18 дней, разница должна быть не больше чем в два раза. Например, если `minDeliveryDays` равно 21, то для `maxDeliveryDays` допускаются значения от 21 до 42. Обязательный параметр, если `type=\"DEPOT\"` или `type=\"MIXED\"`. Взаимоисключающий с параметром `unspecifiedDeliveryInterval`. + * + * @return self + */ + public function setMaxDeliveryDays($max_delivery_days) + { + if (is_null($max_delivery_days)) { + throw new \InvalidArgumentException('non-nullable max_delivery_days cannot be null'); + } + + if (($max_delivery_days > 60)) { + throw new \InvalidArgumentException('invalid value for $max_delivery_days when calling OutletDeliveryRuleDTO., must be smaller than or equal to 60.'); + } + if (($max_delivery_days < 0)) { + throw new \InvalidArgumentException('invalid value for $max_delivery_days when calling OutletDeliveryRuleDTO., must be bigger than or equal to 0.'); + } + + $this->container['max_delivery_days'] = $max_delivery_days; + + return $this; + } + + /** + * Gets delivery_service_id + * + * @return int|null + */ + public function getDeliveryServiceId() + { + return $this->container['delivery_service_id']; + } + + /** + * Sets delivery_service_id + * + * @param int|null $delivery_service_id Идентификатор службы доставки товаров в точку продаж. Информацию о службе доставки можно получить с помощью запроса [GET delivery/services](../../reference/orders/getDeliveryServices.md). + * + * @return self + */ + public function setDeliveryServiceId($delivery_service_id) + { + if (is_null($delivery_service_id)) { + throw new \InvalidArgumentException('non-nullable delivery_service_id cannot be null'); + } + $this->container['delivery_service_id'] = $delivery_service_id; + + return $this; + } + + /** + * Gets order_before + * + * @return int|null + */ + public function getOrderBefore() + { + return $this->container['order_before']; + } + + /** + * Sets order_before + * + * @param int|null $order_before Час, до которого покупателю нужно сделать заказ, чтобы он был доставлен в точку продаж в сроки от `minDeliveryDays` до `maxDeliveryDays`. Если покупатель оформит заказ после указанного часа, он будет доставлен в сроки от `minDeliveryDays` + 1 рабочий день до `maxDeliveryDays` + 1 рабочий день. Значение по умолчанию: `24`. + * + * @return self + */ + public function setOrderBefore($order_before) + { + if (is_null($order_before)) { + throw new \InvalidArgumentException('non-nullable order_before cannot be null'); + } + + if (($order_before > 24)) { + throw new \InvalidArgumentException('invalid value for $order_before when calling OutletDeliveryRuleDTO., must be smaller than or equal to 24.'); + } + if (($order_before < 0)) { + throw new \InvalidArgumentException('invalid value for $order_before when calling OutletDeliveryRuleDTO., must be bigger than or equal to 0.'); + } + + $this->container['order_before'] = $order_before; + + return $this; + } + + /** + * Gets price_free_pickup + * + * @return float|null + */ + public function getPriceFreePickup() + { + return $this->container['price_free_pickup']; + } + + /** + * Sets price_free_pickup + * + * @param float|null $price_free_pickup Цена на товар, начиная с которой действует бесплатный самовывоз товара из точки продаж. + * + * @return self + */ + public function setPriceFreePickup($price_free_pickup) + { + if (is_null($price_free_pickup)) { + throw new \InvalidArgumentException('non-nullable price_free_pickup cannot be null'); + } + $this->container['price_free_pickup'] = $price_free_pickup; + + return $this; + } + + /** + * Gets unspecified_delivery_interval + * + * @return bool|null + */ + public function getUnspecifiedDeliveryInterval() + { + return $this->container['unspecified_delivery_interval']; + } + + /** + * Sets unspecified_delivery_interval + * + * @param bool|null $unspecified_delivery_interval Признак доставки товаров в точку продаж на заказ. Признак выставлен, если: * точный срок доставки в точку продаж заранее неизвестен (например, если магазин собирает несколько заказов для отправки в точку или населенный пункт); * все товары изготавливаются или поставляются на заказ. Возможные значения: * `true` — товары доставляются в точку продаж на заказ. Параметр указывается только со значением `true`. Взаимоисключающий с параметрами `minDeliveryDays` и `maxDeliveryDays`. + * + * @return self + */ + public function setUnspecifiedDeliveryInterval($unspecified_delivery_interval) + { + if (is_null($unspecified_delivery_interval)) { + throw new \InvalidArgumentException('non-nullable unspecified_delivery_interval cannot be null'); + } + $this->container['unspecified_delivery_interval'] = $unspecified_delivery_interval; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OutletLicenseDTO.php b/erp24/lib/yandex_market_api/Model/OutletLicenseDTO.php new file mode 100644 index 00000000..9210573a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OutletLicenseDTO.php @@ -0,0 +1,604 @@ + + */ +class OutletLicenseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OutletLicenseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'outlet_id' => 'int', + 'license_type' => '\OpenAPI\Client\Model\LicenseType', + 'number' => 'string', + 'date_of_issue' => '\DateTime', + 'date_of_expiry' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'outlet_id' => 'int64', + 'license_type' => null, + 'number' => null, + 'date_of_issue' => 'date-time', + 'date_of_expiry' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'outlet_id' => false, + 'license_type' => false, + 'number' => false, + 'date_of_issue' => false, + 'date_of_expiry' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'outlet_id' => 'outletId', + 'license_type' => 'licenseType', + 'number' => 'number', + 'date_of_issue' => 'dateOfIssue', + 'date_of_expiry' => 'dateOfExpiry' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'outlet_id' => 'setOutletId', + 'license_type' => 'setLicenseType', + 'number' => 'setNumber', + 'date_of_issue' => 'setDateOfIssue', + 'date_of_expiry' => 'setDateOfExpiry' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'outlet_id' => 'getOutletId', + 'license_type' => 'getLicenseType', + 'number' => 'getNumber', + 'date_of_issue' => 'getDateOfIssue', + 'date_of_expiry' => 'getDateOfExpiry' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('outlet_id', $data ?? [], null); + $this->setIfExists('license_type', $data ?? [], null); + $this->setIfExists('number', $data ?? [], null); + $this->setIfExists('date_of_issue', $data ?? [], null); + $this->setIfExists('date_of_expiry', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['outlet_id'] === null) { + $invalidProperties[] = "'outlet_id' can't be null"; + } + if (($this->container['outlet_id'] < 1)) { + $invalidProperties[] = "invalid value for 'outlet_id', must be bigger than or equal to 1."; + } + + if ($this->container['license_type'] === null) { + $invalidProperties[] = "'license_type' can't be null"; + } + if ($this->container['number'] === null) { + $invalidProperties[] = "'number' can't be null"; + } + if ($this->container['date_of_issue'] === null) { + $invalidProperties[] = "'date_of_issue' can't be null"; + } + if ($this->container['date_of_expiry'] === null) { + $invalidProperties[] = "'date_of_expiry' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор лицензии. Параметр указывается, только если нужно изменить информацию о существующей лицензии. Ее идентификатор можно узнать с помощью запроса [GET campaigns/{campaignId}/outlets/licenses](../../reference/outlets/getOutletLicenses.md). При передаче информации о новой лицензии указывать идентификатор не нужно. Идентификатор лицензии присваивается Маркетом. Не путайте его с номером, указанным на лицензии: он передается в параметре `number`. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets outlet_id + * + * @return int + */ + public function getOutletId() + { + return $this->container['outlet_id']; + } + + /** + * Sets outlet_id + * + * @param int $outlet_id Идентификатор точки продаж, для которой действительна лицензия. + * + * @return self + */ + public function setOutletId($outlet_id) + { + if (is_null($outlet_id)) { + throw new \InvalidArgumentException('non-nullable outlet_id cannot be null'); + } + + if (($outlet_id < 1)) { + throw new \InvalidArgumentException('invalid value for $outlet_id when calling OutletLicenseDTO., must be bigger than or equal to 1.'); + } + + $this->container['outlet_id'] = $outlet_id; + + return $this; + } + + /** + * Gets license_type + * + * @return \OpenAPI\Client\Model\LicenseType + */ + public function getLicenseType() + { + return $this->container['license_type']; + } + + /** + * Sets license_type + * + * @param \OpenAPI\Client\Model\LicenseType $license_type license_type + * + * @return self + */ + public function setLicenseType($license_type) + { + if (is_null($license_type)) { + throw new \InvalidArgumentException('non-nullable license_type cannot be null'); + } + $this->container['license_type'] = $license_type; + + return $this; + } + + /** + * Gets number + * + * @return string + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param string $number Номер лицензии. + * + * @return self + */ + public function setNumber($number) + { + if (is_null($number)) { + throw new \InvalidArgumentException('non-nullable number cannot be null'); + } + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets date_of_issue + * + * @return \DateTime + */ + public function getDateOfIssue() + { + return $this->container['date_of_issue']; + } + + /** + * Sets date_of_issue + * + * @param \DateTime $date_of_issue Дата выдачи лицензии. Формат даты: ISO 8601 со смещением относительно UTC. Нужно передать дату, указанную на лицензии, время `00:00:00` и часовой пояс, соответствующий региону точки продаж. Например, если лицензия для точки продаж в Москве выдана 13 ноября 2017 года, то параметр должен иметь значение `2017-11-13T00:00:00+03:00`. Не может быть позже даты окончания срока действия, указанной в параметре `dateOfExpiry`. + * + * @return self + */ + public function setDateOfIssue($date_of_issue) + { + if (is_null($date_of_issue)) { + throw new \InvalidArgumentException('non-nullable date_of_issue cannot be null'); + } + $this->container['date_of_issue'] = $date_of_issue; + + return $this; + } + + /** + * Gets date_of_expiry + * + * @return \DateTime + */ + public function getDateOfExpiry() + { + return $this->container['date_of_expiry']; + } + + /** + * Sets date_of_expiry + * + * @param \DateTime $date_of_expiry Дата окончания действия лицензии. Формат даты: ISO 8601 со смещением относительно UTC. Нужно передать дату, указанную на лицензии, время `00:00:00` и часовой пояс, соответствующий региону точки продаж. Например, если действие лицензии для точки продаж в Москве заканчивается 20 ноября 2022 года, то параметр должен иметь значение `2022-11-20T00:00:00+03:00`. Не может быть раньше даты выдачи, указанной в параметре `dateOfIssue`. + * + * @return self + */ + public function setDateOfExpiry($date_of_expiry) + { + if (is_null($date_of_expiry)) { + throw new \InvalidArgumentException('non-nullable date_of_expiry cannot be null'); + } + $this->container['date_of_expiry'] = $date_of_expiry; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OutletLicensesResponseDTO.php b/erp24/lib/yandex_market_api/Model/OutletLicensesResponseDTO.php new file mode 100644 index 00000000..fcc94af1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OutletLicensesResponseDTO.php @@ -0,0 +1,413 @@ + + */ +class OutletLicensesResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OutletLicensesResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'licenses' => '\OpenAPI\Client\Model\FullOutletLicenseDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'licenses' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'licenses' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'licenses' => 'licenses' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'licenses' => 'setLicenses' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'licenses' => 'getLicenses' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('licenses', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['licenses'] === null) { + $invalidProperties[] = "'licenses' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets licenses + * + * @return \OpenAPI\Client\Model\FullOutletLicenseDTO[] + */ + public function getLicenses() + { + return $this->container['licenses']; + } + + /** + * Sets licenses + * + * @param \OpenAPI\Client\Model\FullOutletLicenseDTO[] $licenses Список лицензий. + * + * @return self + */ + public function setLicenses($licenses) + { + if (is_null($licenses)) { + throw new \InvalidArgumentException('non-nullable licenses cannot be null'); + } + $this->container['licenses'] = $licenses; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OutletResponseDTO.php b/erp24/lib/yandex_market_api/Model/OutletResponseDTO.php new file mode 100644 index 00000000..7fdaa9d7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OutletResponseDTO.php @@ -0,0 +1,410 @@ + + */ +class OutletResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OutletResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор точки продаж, присвоенный Маркетом. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OutletStatusType.php b/erp24/lib/yandex_market_api/Model/OutletStatusType.php new file mode 100644 index 00000000..e7b0cf80 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OutletStatusType.php @@ -0,0 +1,72 @@ + + */ +class OutletWorkingScheduleDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OutletWorkingScheduleDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'work_in_holiday' => 'bool', + 'schedule_items' => '\OpenAPI\Client\Model\OutletWorkingScheduleItemDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'work_in_holiday' => null, + 'schedule_items' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'work_in_holiday' => false, + 'schedule_items' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'work_in_holiday' => 'workInHoliday', + 'schedule_items' => 'scheduleItems' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'work_in_holiday' => 'setWorkInHoliday', + 'schedule_items' => 'setScheduleItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'work_in_holiday' => 'getWorkInHoliday', + 'schedule_items' => 'getScheduleItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('work_in_holiday', $data ?? [], null); + $this->setIfExists('schedule_items', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['schedule_items'] === null) { + $invalidProperties[] = "'schedule_items' can't be null"; + } + if ((count($this->container['schedule_items']) < 1)) { + $invalidProperties[] = "invalid value for 'schedule_items', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets work_in_holiday + * + * @return bool|null + */ + public function getWorkInHoliday() + { + return $this->container['work_in_holiday']; + } + + /** + * Sets work_in_holiday + * + * @param bool|null $work_in_holiday Признак, работает ли точка продаж в дни государственных праздников. Возможные значения: * `false` — точка продаж не работает в дни государственных праздников. * `true` — точка продаж работает в дни государственных праздников. + * + * @return self + */ + public function setWorkInHoliday($work_in_holiday) + { + if (is_null($work_in_holiday)) { + throw new \InvalidArgumentException('non-nullable work_in_holiday cannot be null'); + } + $this->container['work_in_holiday'] = $work_in_holiday; + + return $this; + } + + /** + * Gets schedule_items + * + * @return \OpenAPI\Client\Model\OutletWorkingScheduleItemDTO[] + */ + public function getScheduleItems() + { + return $this->container['schedule_items']; + } + + /** + * Sets schedule_items + * + * @param \OpenAPI\Client\Model\OutletWorkingScheduleItemDTO[] $schedule_items Список расписаний работы точки продаж. + * + * @return self + */ + public function setScheduleItems($schedule_items) + { + if (is_null($schedule_items)) { + throw new \InvalidArgumentException('non-nullable schedule_items cannot be null'); + } + + + if ((count($schedule_items) < 1)) { + throw new \InvalidArgumentException('invalid length for $schedule_items when calling OutletWorkingScheduleDTO., number of items must be greater than or equal to 1.'); + } + $this->container['schedule_items'] = $schedule_items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/OutletWorkingScheduleItemDTO.php b/erp24/lib/yandex_market_api/Model/OutletWorkingScheduleItemDTO.php new file mode 100644 index 00000000..5df690df --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/OutletWorkingScheduleItemDTO.php @@ -0,0 +1,542 @@ + + */ +class OutletWorkingScheduleItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'OutletWorkingScheduleItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'start_day' => '\OpenAPI\Client\Model\DayOfWeekType', + 'end_day' => '\OpenAPI\Client\Model\DayOfWeekType', + 'start_time' => 'string', + 'end_time' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'start_day' => null, + 'end_day' => null, + 'start_time' => null, + 'end_time' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'start_day' => false, + 'end_day' => false, + 'start_time' => false, + 'end_time' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'start_day' => 'startDay', + 'end_day' => 'endDay', + 'start_time' => 'startTime', + 'end_time' => 'endTime' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'start_day' => 'setStartDay', + 'end_day' => 'setEndDay', + 'start_time' => 'setStartTime', + 'end_time' => 'setEndTime' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'start_day' => 'getStartDay', + 'end_day' => 'getEndDay', + 'start_time' => 'getStartTime', + 'end_time' => 'getEndTime' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('start_day', $data ?? [], null); + $this->setIfExists('end_day', $data ?? [], null); + $this->setIfExists('start_time', $data ?? [], null); + $this->setIfExists('end_time', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['start_day'] === null) { + $invalidProperties[] = "'start_day' can't be null"; + } + if ($this->container['end_day'] === null) { + $invalidProperties[] = "'end_day' can't be null"; + } + if ($this->container['start_time'] === null) { + $invalidProperties[] = "'start_time' can't be null"; + } + if (!preg_match("/^([0-1][0-9]|2[0-3]):[0-5][0-9]$/", $this->container['start_time'])) { + $invalidProperties[] = "invalid value for 'start_time', must be conform to the pattern /^([0-1][0-9]|2[0-3]):[0-5][0-9]$/."; + } + + if ($this->container['end_time'] === null) { + $invalidProperties[] = "'end_time' can't be null"; + } + if (!preg_match("/^([0-1][0-9]|2[0-3]):[0-5][0-9]$/", $this->container['end_time'])) { + $invalidProperties[] = "invalid value for 'end_time', must be conform to the pattern /^([0-1][0-9]|2[0-3]):[0-5][0-9]$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets start_day + * + * @return \OpenAPI\Client\Model\DayOfWeekType + */ + public function getStartDay() + { + return $this->container['start_day']; + } + + /** + * Sets start_day + * + * @param \OpenAPI\Client\Model\DayOfWeekType $start_day start_day + * + * @return self + */ + public function setStartDay($start_day) + { + if (is_null($start_day)) { + throw new \InvalidArgumentException('non-nullable start_day cannot be null'); + } + $this->container['start_day'] = $start_day; + + return $this; + } + + /** + * Gets end_day + * + * @return \OpenAPI\Client\Model\DayOfWeekType + */ + public function getEndDay() + { + return $this->container['end_day']; + } + + /** + * Sets end_day + * + * @param \OpenAPI\Client\Model\DayOfWeekType $end_day end_day + * + * @return self + */ + public function setEndDay($end_day) + { + if (is_null($end_day)) { + throw new \InvalidArgumentException('non-nullable end_day cannot be null'); + } + $this->container['end_day'] = $end_day; + + return $this; + } + + /** + * Gets start_time + * + * @return string + */ + public function getStartTime() + { + return $this->container['start_time']; + } + + /** + * Sets start_time + * + * @param string $start_time Точка продаж работает c указанного часа. Формат: `ЧЧ:ММ`. + * + * @return self + */ + public function setStartTime($start_time) + { + if (is_null($start_time)) { + throw new \InvalidArgumentException('non-nullable start_time cannot be null'); + } + + if ((!preg_match("/^([0-1][0-9]|2[0-3]):[0-5][0-9]$/", ObjectSerializer::toString($start_time)))) { + throw new \InvalidArgumentException("invalid value for \$start_time when calling OutletWorkingScheduleItemDTO., must conform to the pattern /^([0-1][0-9]|2[0-3]):[0-5][0-9]$/."); + } + + $this->container['start_time'] = $start_time; + + return $this; + } + + /** + * Gets end_time + * + * @return string + */ + public function getEndTime() + { + return $this->container['end_time']; + } + + /** + * Sets end_time + * + * @param string $end_time Точка продаж работает до указанного часа. Формат: `ЧЧ:ММ`. + * + * @return self + */ + public function setEndTime($end_time) + { + if (is_null($end_time)) { + throw new \InvalidArgumentException('non-nullable end_time cannot be null'); + } + + if ((!preg_match("/^([0-1][0-9]|2[0-3]):[0-5][0-9]$/", ObjectSerializer::toString($end_time)))) { + throw new \InvalidArgumentException("invalid value for \$end_time when calling OutletWorkingScheduleItemDTO., must conform to the pattern /^([0-1][0-9]|2[0-3]):[0-5][0-9]$/."); + } + + $this->container['end_time'] = $end_time; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PageFormatType.php b/erp24/lib/yandex_market_api/Model/PageFormatType.php new file mode 100644 index 00000000..7ae98290 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PageFormatType.php @@ -0,0 +1,63 @@ + + */ +class PagedReturnsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PagedReturnsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO', + 'returns' => '\OpenAPI\Client\Model\ReturnDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'paging' => null, + 'returns' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'paging' => false, + 'returns' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'paging' => 'paging', + 'returns' => 'returns' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'paging' => 'setPaging', + 'returns' => 'setReturns' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'paging' => 'getPaging', + 'returns' => 'getReturns' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('paging', $data ?? [], null); + $this->setIfExists('returns', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['returns'] === null) { + $invalidProperties[] = "'returns' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + + /** + * Gets returns + * + * @return \OpenAPI\Client\Model\ReturnDTO[] + */ + public function getReturns() + { + return $this->container['returns']; + } + + /** + * Sets returns + * + * @param \OpenAPI\Client\Model\ReturnDTO[] $returns Список возвратов. + * + * @return self + */ + public function setReturns($returns) + { + if (is_null($returns)) { + throw new \InvalidArgumentException('non-nullable returns cannot be null'); + } + $this->container['returns'] = $returns; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PalletsCountDTO.php b/erp24/lib/yandex_market_api/Model/PalletsCountDTO.php new file mode 100644 index 00000000..7a59e38a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PalletsCountDTO.php @@ -0,0 +1,462 @@ + + */ +class PalletsCountDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PalletsCountDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'planned' => 'int', + 'fact' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'planned' => 'int32', + 'fact' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'planned' => false, + 'fact' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'planned' => 'planned', + 'fact' => 'fact' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'planned' => 'setPlanned', + 'fact' => 'setFact' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'planned' => 'getPlanned', + 'fact' => 'getFact' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('planned', $data ?? [], null); + $this->setIfExists('fact', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['planned']) && ($this->container['planned'] < 0)) { + $invalidProperties[] = "invalid value for 'planned', must be bigger than or equal to 0."; + } + + if (!is_null($this->container['fact']) && ($this->container['fact'] < 0)) { + $invalidProperties[] = "invalid value for 'fact', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets planned + * + * @return int|null + */ + public function getPlanned() + { + return $this->container['planned']; + } + + /** + * Sets planned + * + * @param int|null $planned Количество палет, которое заявил продавец. + * + * @return self + */ + public function setPlanned($planned) + { + if (is_null($planned)) { + throw new \InvalidArgumentException('non-nullable planned cannot be null'); + } + + if (($planned < 0)) { + throw new \InvalidArgumentException('invalid value for $planned when calling PalletsCountDTO., must be bigger than or equal to 0.'); + } + + $this->container['planned'] = $planned; + + return $this; + } + + /** + * Gets fact + * + * @return int|null + */ + public function getFact() + { + return $this->container['fact']; + } + + /** + * Sets fact + * + * @param int|null $fact Количество палет, которое приняли в сортировочном центре. + * + * @return self + */ + public function setFact($fact) + { + if (is_null($fact)) { + throw new \InvalidArgumentException('non-nullable fact cannot be null'); + } + + if (($fact < 0)) { + throw new \InvalidArgumentException('invalid value for $fact when calling PalletsCountDTO., must be bigger than or equal to 0.'); + } + + $this->container['fact'] = $fact; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ParameterType.php b/erp24/lib/yandex_market_api/Model/ParameterType.php new file mode 100644 index 00000000..145924b7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ParameterType.php @@ -0,0 +1,69 @@ + + */ +class ParameterValueConstraintsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ParameterValueConstraintsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'min_value' => 'float', + 'max_value' => 'float', + 'max_length' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'min_value' => 'double', + 'max_value' => 'double', + 'max_length' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'min_value' => false, + 'max_value' => false, + 'max_length' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'min_value' => 'minValue', + 'max_value' => 'maxValue', + 'max_length' => 'maxLength' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'min_value' => 'setMinValue', + 'max_value' => 'setMaxValue', + 'max_length' => 'setMaxLength' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'min_value' => 'getMinValue', + 'max_value' => 'getMaxValue', + 'max_length' => 'getMaxLength' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('min_value', $data ?? [], null); + $this->setIfExists('max_value', $data ?? [], null); + $this->setIfExists('max_length', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets min_value + * + * @return float|null + */ + public function getMinValue() + { + return $this->container['min_value']; + } + + /** + * Sets min_value + * + * @param float|null $min_value Минимальное число. + * + * @return self + */ + public function setMinValue($min_value) + { + if (is_null($min_value)) { + throw new \InvalidArgumentException('non-nullable min_value cannot be null'); + } + $this->container['min_value'] = $min_value; + + return $this; + } + + /** + * Gets max_value + * + * @return float|null + */ + public function getMaxValue() + { + return $this->container['max_value']; + } + + /** + * Sets max_value + * + * @param float|null $max_value Максимальное число. + * + * @return self + */ + public function setMaxValue($max_value) + { + if (is_null($max_value)) { + throw new \InvalidArgumentException('non-nullable max_value cannot be null'); + } + $this->container['max_value'] = $max_value; + + return $this; + } + + /** + * Gets max_length + * + * @return int|null + */ + public function getMaxLength() + { + return $this->container['max_length']; + } + + /** + * Sets max_length + * + * @param int|null $max_length Максимальная длина текста. + * + * @return self + */ + public function setMaxLength($max_length) + { + if (is_null($max_length)) { + throw new \InvalidArgumentException('non-nullable max_length cannot be null'); + } + $this->container['max_length'] = $max_length; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ParameterValueDTO.php b/erp24/lib/yandex_market_api/Model/ParameterValueDTO.php new file mode 100644 index 00000000..ef82b994 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ParameterValueDTO.php @@ -0,0 +1,524 @@ + + */ +class ParameterValueDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ParameterValueDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'parameter_id' => 'int', + 'unit_id' => 'int', + 'value_id' => 'int', + 'value' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'parameter_id' => 'int64', + 'unit_id' => 'int64', + 'value_id' => 'int64', + 'value' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'parameter_id' => false, + 'unit_id' => false, + 'value_id' => false, + 'value' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'parameter_id' => 'parameterId', + 'unit_id' => 'unitId', + 'value_id' => 'valueId', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'parameter_id' => 'setParameterId', + 'unit_id' => 'setUnitId', + 'value_id' => 'setValueId', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'parameter_id' => 'getParameterId', + 'unit_id' => 'getUnitId', + 'value_id' => 'getValueId', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('parameter_id', $data ?? [], null); + $this->setIfExists('unit_id', $data ?? [], null); + $this->setIfExists('value_id', $data ?? [], null); + $this->setIfExists('value', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['parameter_id'] === null) { + $invalidProperties[] = "'parameter_id' can't be null"; + } + if (($this->container['parameter_id'] < 1)) { + $invalidProperties[] = "invalid value for 'parameter_id', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets parameter_id + * + * @return int + */ + public function getParameterId() + { + return $this->container['parameter_id']; + } + + /** + * Sets parameter_id + * + * @param int $parameter_id Идентификатор характеристики. + * + * @return self + */ + public function setParameterId($parameter_id) + { + if (is_null($parameter_id)) { + throw new \InvalidArgumentException('non-nullable parameter_id cannot be null'); + } + + if (($parameter_id < 1)) { + throw new \InvalidArgumentException('invalid value for $parameter_id when calling ParameterValueDTO., must be bigger than or equal to 1.'); + } + + $this->container['parameter_id'] = $parameter_id; + + return $this; + } + + /** + * Gets unit_id + * + * @return int|null + */ + public function getUnitId() + { + return $this->container['unit_id']; + } + + /** + * Sets unit_id + * + * @param int|null $unit_id Идентификатор единицы измерения. Если вы не передали параметр `unitId`, используется единица измерения по умолчанию. + * + * @return self + */ + public function setUnitId($unit_id) + { + if (is_null($unit_id)) { + throw new \InvalidArgumentException('non-nullable unit_id cannot be null'); + } + $this->container['unit_id'] = $unit_id; + + return $this; + } + + /** + * Gets value_id + * + * @return int|null + */ + public function getValueId() + { + return $this->container['value_id']; + } + + /** + * Sets value_id + * + * @param int|null $value_id Идентификатор значения. Обязательно указывайте идентификатор, если передаете значение из перечня допустимых значений, полученного от Маркета. Только для характеристик типа `ENUM`. + * + * @return self + */ + public function setValueId($value_id) + { + if (is_null($value_id)) { + throw new \InvalidArgumentException('non-nullable value_id cannot be null'); + } + $this->container['value_id'] = $value_id; + + return $this; + } + + /** + * Gets value + * + * @return string|null + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string|null $value Значение. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ParameterValueOptionDTO.php b/erp24/lib/yandex_market_api/Model/ParameterValueOptionDTO.php new file mode 100644 index 00000000..2011edfa --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ParameterValueOptionDTO.php @@ -0,0 +1,484 @@ + + */ +class ParameterValueOptionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ParameterValueOptionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'value' => 'string', + 'description' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'value' => null, + 'description' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'value' => false, + 'description' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'value' => 'value', + 'description' => 'description' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'value' => 'setValue', + 'description' => 'setDescription' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'value' => 'getValue', + 'description' => 'getDescription' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор значения. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value Значение. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Описание значения. + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + $this->container['description'] = $description; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ParcelBoxDTO.php b/erp24/lib/yandex_market_api/Model/ParcelBoxDTO.php new file mode 100644 index 00000000..263f3936 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ParcelBoxDTO.php @@ -0,0 +1,453 @@ + + */ +class ParcelBoxDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ParcelBoxDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'fulfilment_id' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'fulfilment_id' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'fulfilment_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'fulfilment_id' => 'fulfilmentId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'fulfilment_id' => 'setFulfilmentId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'fulfilment_id' => 'getFulfilmentId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('fulfilment_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['fulfilment_id']) && !preg_match("/^[\\p{Alnum}- ]*$/", $this->container['fulfilment_id'])) { + $invalidProperties[] = "invalid value for 'fulfilment_id', must be conform to the pattern /^[\\p{Alnum}- ]*$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets fulfilment_id + * + * @return string|null + */ + public function getFulfilmentId() + { + return $this->container['fulfilment_id']; + } + + /** + * Sets fulfilment_id + * + * @param string|null $fulfilment_id {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} + * + * @return self + */ + public function setFulfilmentId($fulfilment_id) + { + if (is_null($fulfilment_id)) { + throw new \InvalidArgumentException('non-nullable fulfilment_id cannot be null'); + } + + if ((!preg_match("/^[\\p{Alnum}- ]*$/", ObjectSerializer::toString($fulfilment_id)))) { + throw new \InvalidArgumentException("invalid value for \$fulfilment_id when calling ParcelBoxDTO., must conform to the pattern /^[\\p{Alnum}- ]*$/."); + } + + $this->container['fulfilment_id'] = $fulfilment_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ParcelBoxLabelDTO.php b/erp24/lib/yandex_market_api/Model/ParcelBoxLabelDTO.php new file mode 100644 index 00000000..7e5a11e5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ParcelBoxLabelDTO.php @@ -0,0 +1,851 @@ + + */ +class ParcelBoxLabelDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ParcelBoxLabelDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'url' => 'string', + 'supplier_name' => 'string', + 'delivery_service_name' => 'string', + 'order_id' => 'int', + 'order_num' => 'string', + 'recipient_name' => 'string', + 'box_id' => 'int', + 'fulfilment_id' => 'string', + 'place' => 'string', + 'weight' => 'string', + 'delivery_service_id' => 'string', + 'delivery_address' => 'string', + 'shipment_date' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'url' => null, + 'supplier_name' => null, + 'delivery_service_name' => null, + 'order_id' => 'int64', + 'order_num' => null, + 'recipient_name' => null, + 'box_id' => 'int64', + 'fulfilment_id' => null, + 'place' => null, + 'weight' => null, + 'delivery_service_id' => null, + 'delivery_address' => null, + 'shipment_date' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'url' => false, + 'supplier_name' => false, + 'delivery_service_name' => false, + 'order_id' => false, + 'order_num' => false, + 'recipient_name' => false, + 'box_id' => false, + 'fulfilment_id' => false, + 'place' => false, + 'weight' => false, + 'delivery_service_id' => false, + 'delivery_address' => false, + 'shipment_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'url' => 'url', + 'supplier_name' => 'supplierName', + 'delivery_service_name' => 'deliveryServiceName', + 'order_id' => 'orderId', + 'order_num' => 'orderNum', + 'recipient_name' => 'recipientName', + 'box_id' => 'boxId', + 'fulfilment_id' => 'fulfilmentId', + 'place' => 'place', + 'weight' => 'weight', + 'delivery_service_id' => 'deliveryServiceId', + 'delivery_address' => 'deliveryAddress', + 'shipment_date' => 'shipmentDate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'url' => 'setUrl', + 'supplier_name' => 'setSupplierName', + 'delivery_service_name' => 'setDeliveryServiceName', + 'order_id' => 'setOrderId', + 'order_num' => 'setOrderNum', + 'recipient_name' => 'setRecipientName', + 'box_id' => 'setBoxId', + 'fulfilment_id' => 'setFulfilmentId', + 'place' => 'setPlace', + 'weight' => 'setWeight', + 'delivery_service_id' => 'setDeliveryServiceId', + 'delivery_address' => 'setDeliveryAddress', + 'shipment_date' => 'setShipmentDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'url' => 'getUrl', + 'supplier_name' => 'getSupplierName', + 'delivery_service_name' => 'getDeliveryServiceName', + 'order_id' => 'getOrderId', + 'order_num' => 'getOrderNum', + 'recipient_name' => 'getRecipientName', + 'box_id' => 'getBoxId', + 'fulfilment_id' => 'getFulfilmentId', + 'place' => 'getPlace', + 'weight' => 'getWeight', + 'delivery_service_id' => 'getDeliveryServiceId', + 'delivery_address' => 'getDeliveryAddress', + 'shipment_date' => 'getShipmentDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('url', $data ?? [], null); + $this->setIfExists('supplier_name', $data ?? [], null); + $this->setIfExists('delivery_service_name', $data ?? [], null); + $this->setIfExists('order_id', $data ?? [], null); + $this->setIfExists('order_num', $data ?? [], null); + $this->setIfExists('recipient_name', $data ?? [], null); + $this->setIfExists('box_id', $data ?? [], null); + $this->setIfExists('fulfilment_id', $data ?? [], null); + $this->setIfExists('place', $data ?? [], null); + $this->setIfExists('weight', $data ?? [], null); + $this->setIfExists('delivery_service_id', $data ?? [], null); + $this->setIfExists('delivery_address', $data ?? [], null); + $this->setIfExists('shipment_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['url'] === null) { + $invalidProperties[] = "'url' can't be null"; + } + if ($this->container['supplier_name'] === null) { + $invalidProperties[] = "'supplier_name' can't be null"; + } + if ($this->container['delivery_service_name'] === null) { + $invalidProperties[] = "'delivery_service_name' can't be null"; + } + if ($this->container['order_id'] === null) { + $invalidProperties[] = "'order_id' can't be null"; + } + if ($this->container['order_num'] === null) { + $invalidProperties[] = "'order_num' can't be null"; + } + if ($this->container['recipient_name'] === null) { + $invalidProperties[] = "'recipient_name' can't be null"; + } + if ($this->container['box_id'] === null) { + $invalidProperties[] = "'box_id' can't be null"; + } + if ($this->container['fulfilment_id'] === null) { + $invalidProperties[] = "'fulfilment_id' can't be null"; + } + if ($this->container['place'] === null) { + $invalidProperties[] = "'place' can't be null"; + } + if ($this->container['weight'] === null) { + $invalidProperties[] = "'weight' can't be null"; + } + if ($this->container['delivery_service_id'] === null) { + $invalidProperties[] = "'delivery_service_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets url + * + * @return string + */ + public function getUrl() + { + return $this->container['url']; + } + + /** + * Sets url + * + * @param string $url Соответствует URL, по которому выполняется запрос [GET campaigns/{campaignId}/orders/{orderId}/delivery/shipments/{shipmentId}/boxes/{boxId}/label](../../reference/orders/generateOrderLabel.md). + * + * @return self + */ + public function setUrl($url) + { + if (is_null($url)) { + throw new \InvalidArgumentException('non-nullable url cannot be null'); + } + $this->container['url'] = $url; + + return $this; + } + + /** + * Gets supplier_name + * + * @return string + */ + public function getSupplierName() + { + return $this->container['supplier_name']; + } + + /** + * Sets supplier_name + * + * @param string $supplier_name Юридическое название магазина. + * + * @return self + */ + public function setSupplierName($supplier_name) + { + if (is_null($supplier_name)) { + throw new \InvalidArgumentException('non-nullable supplier_name cannot be null'); + } + $this->container['supplier_name'] = $supplier_name; + + return $this; + } + + /** + * Gets delivery_service_name + * + * @return string + */ + public function getDeliveryServiceName() + { + return $this->container['delivery_service_name']; + } + + /** + * Sets delivery_service_name + * + * @param string $delivery_service_name Юридическое название службы доставки. + * + * @return self + */ + public function setDeliveryServiceName($delivery_service_name) + { + if (is_null($delivery_service_name)) { + throw new \InvalidArgumentException('non-nullable delivery_service_name cannot be null'); + } + $this->container['delivery_service_name'] = $delivery_service_name; + + return $this; + } + + /** + * Gets order_id + * + * @return int + */ + public function getOrderId() + { + return $this->container['order_id']; + } + + /** + * Sets order_id + * + * @param int $order_id Идентификатор заказа в системе Маркета. + * + * @return self + */ + public function setOrderId($order_id) + { + if (is_null($order_id)) { + throw new \InvalidArgumentException('non-nullable order_id cannot be null'); + } + $this->container['order_id'] = $order_id; + + return $this; + } + + /** + * Gets order_num + * + * @return string + */ + public function getOrderNum() + { + return $this->container['order_num']; + } + + /** + * Sets order_num + * + * @param string $order_num Идентификатор заказа в информационной системе магазина. Совпадает с `orderId`, если Маркету неизвестен номер заказа в системе магазина. + * + * @return self + */ + public function setOrderNum($order_num) + { + if (is_null($order_num)) { + throw new \InvalidArgumentException('non-nullable order_num cannot be null'); + } + $this->container['order_num'] = $order_num; + + return $this; + } + + /** + * Gets recipient_name + * + * @return string + */ + public function getRecipientName() + { + return $this->container['recipient_name']; + } + + /** + * Sets recipient_name + * + * @param string $recipient_name Фамилия и инициалы получателя заказа. + * + * @return self + */ + public function setRecipientName($recipient_name) + { + if (is_null($recipient_name)) { + throw new \InvalidArgumentException('non-nullable recipient_name cannot be null'); + } + $this->container['recipient_name'] = $recipient_name; + + return $this; + } + + /** + * Gets box_id + * + * @return int + */ + public function getBoxId() + { + return $this->container['box_id']; + } + + /** + * Sets box_id + * + * @param int $box_id Идентификатор коробки. + * + * @return self + */ + public function setBoxId($box_id) + { + if (is_null($box_id)) { + throw new \InvalidArgumentException('non-nullable box_id cannot be null'); + } + $this->container['box_id'] = $box_id; + + return $this; + } + + /** + * Gets fulfilment_id + * + * @return string + */ + public function getFulfilmentId() + { + return $this->container['fulfilment_id']; + } + + /** + * Sets fulfilment_id + * + * @param string $fulfilment_id Идентификатор коробки в информационной системе магазина. Возвращается в формате: `номер заказа на Маркете-номер коробки`. Например, `7206821‑1`, `7206821‑2` и т. д. + * + * @return self + */ + public function setFulfilmentId($fulfilment_id) + { + if (is_null($fulfilment_id)) { + throw new \InvalidArgumentException('non-nullable fulfilment_id cannot be null'); + } + $this->container['fulfilment_id'] = $fulfilment_id; + + return $this; + } + + /** + * Gets place + * + * @return string + */ + public function getPlace() + { + return $this->container['place']; + } + + /** + * Sets place + * + * @param string $place Номер коробки в заказе. Возвращается в формате: `номер места/общее количество мест`. + * + * @return self + */ + public function setPlace($place) + { + if (is_null($place)) { + throw new \InvalidArgumentException('non-nullable place cannot be null'); + } + $this->container['place'] = $place; + + return $this; + } + + /** + * Gets weight + * + * @return string + */ + public function getWeight() + { + return $this->container['weight']; + } + + /** + * Sets weight + * + * @param string $weight {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Общая масса всех товаров в заказе. Возвращается в формате: `weight кг`. + * + * @return self + */ + public function setWeight($weight) + { + if (is_null($weight)) { + throw new \InvalidArgumentException('non-nullable weight cannot be null'); + } + $this->container['weight'] = $weight; + + return $this; + } + + /** + * Gets delivery_service_id + * + * @return string + */ + public function getDeliveryServiceId() + { + return $this->container['delivery_service_id']; + } + + /** + * Sets delivery_service_id + * + * @param string $delivery_service_id Идентификатор службы доставки. Информацию о службе доставки можно получить с помощью запроса [GET delivery/services](../../reference/orders/getDeliveryServices.md). + * + * @return self + */ + public function setDeliveryServiceId($delivery_service_id) + { + if (is_null($delivery_service_id)) { + throw new \InvalidArgumentException('non-nullable delivery_service_id cannot be null'); + } + $this->container['delivery_service_id'] = $delivery_service_id; + + return $this; + } + + /** + * Gets delivery_address + * + * @return string|null + */ + public function getDeliveryAddress() + { + return $this->container['delivery_address']; + } + + /** + * Sets delivery_address + * + * @param string|null $delivery_address Адрес получателя. + * + * @return self + */ + public function setDeliveryAddress($delivery_address) + { + if (is_null($delivery_address)) { + throw new \InvalidArgumentException('non-nullable delivery_address cannot be null'); + } + $this->container['delivery_address'] = $delivery_address; + + return $this; + } + + /** + * Gets shipment_date + * + * @return string|null + */ + public function getShipmentDate() + { + return $this->container['shipment_date']; + } + + /** + * Sets shipment_date + * + * @param string|null $shipment_date Дата отгрузки в формате `dd.MM.yyyy`. + * + * @return self + */ + public function setShipmentDate($shipment_date) + { + if (is_null($shipment_date)) { + throw new \InvalidArgumentException('non-nullable shipment_date cannot be null'); + } + $this->container['shipment_date'] = $shipment_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ParcelDTO.php b/erp24/lib/yandex_market_api/Model/ParcelDTO.php new file mode 100644 index 00000000..67812fc3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ParcelDTO.php @@ -0,0 +1,422 @@ + + */ +class ParcelDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ParcelDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'boxes' => '\OpenAPI\Client\Model\ParcelBoxDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'boxes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'boxes' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'boxes' => 'boxes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'boxes' => 'setBoxes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'boxes' => 'getBoxes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('boxes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['boxes'] === null) { + $invalidProperties[] = "'boxes' can't be null"; + } + if ((count($this->container['boxes']) < 1)) { + $invalidProperties[] = "invalid value for 'boxes', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets boxes + * + * @return \OpenAPI\Client\Model\ParcelBoxDTO[] + */ + public function getBoxes() + { + return $this->container['boxes']; + } + + /** + * Sets boxes + * + * @param \OpenAPI\Client\Model\ParcelBoxDTO[] $boxes Список грузовых мест. Маркет определяет количество мест по длине этого списка. + * + * @return self + */ + public function setBoxes($boxes) + { + if (is_null($boxes)) { + throw new \InvalidArgumentException('non-nullable boxes cannot be null'); + } + + + if ((count($boxes) < 1)) { + throw new \InvalidArgumentException('invalid length for $boxes when calling ParcelDTO., number of items must be greater than or equal to 1.'); + } + $this->container['boxes'] = $boxes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PartnerShipmentWarehouseDTO.php b/erp24/lib/yandex_market_api/Model/PartnerShipmentWarehouseDTO.php new file mode 100644 index 00000000..d3c38518 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PartnerShipmentWarehouseDTO.php @@ -0,0 +1,490 @@ + + */ +class PartnerShipmentWarehouseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PartnerShipmentWarehouseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'address' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'address' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'address' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'address' => 'address' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'address' => 'setAddress' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'address' => 'getAddress' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('address', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if (($this->container['id'] < 1)) { + $invalidProperties[] = "invalid value for 'id', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор склада отправления. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + if (($id < 1)) { + throw new \InvalidArgumentException('invalid value for $id when calling PartnerShipmentWarehouseDTO., must be bigger than or equal to 1.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Наименование склада отправления. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets address + * + * @return string|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param string|null $address Адрес склада отправления. + * + * @return self + */ + public function setAddress($address) + { + if (is_null($address)) { + throw new \InvalidArgumentException('non-nullable address cannot be null'); + } + $this->container['address'] = $address; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PaymentFrequencyType.php b/erp24/lib/yandex_market_api/Model/PaymentFrequencyType.php new file mode 100644 index 00000000..49de435b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PaymentFrequencyType.php @@ -0,0 +1,69 @@ + + */ +class PickupAddressDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PickupAddressDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'country' => 'string', + 'city' => 'string', + 'street' => 'string', + 'house' => 'string', + 'postcode' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'country' => null, + 'city' => null, + 'street' => null, + 'house' => null, + 'postcode' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'country' => false, + 'city' => false, + 'street' => false, + 'house' => false, + 'postcode' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'country' => 'country', + 'city' => 'city', + 'street' => 'street', + 'house' => 'house', + 'postcode' => 'postcode' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'country' => 'setCountry', + 'city' => 'setCity', + 'street' => 'setStreet', + 'house' => 'setHouse', + 'postcode' => 'setPostcode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'country' => 'getCountry', + 'city' => 'getCity', + 'street' => 'getStreet', + 'house' => 'getHouse', + 'postcode' => 'getPostcode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('country', $data ?? [], null); + $this->setIfExists('city', $data ?? [], null); + $this->setIfExists('street', $data ?? [], null); + $this->setIfExists('house', $data ?? [], null); + $this->setIfExists('postcode', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets country + * + * @return string|null + */ + public function getCountry() + { + return $this->container['country']; + } + + /** + * Sets country + * + * @param string|null $country Страна. + * + * @return self + */ + public function setCountry($country) + { + if (is_null($country)) { + throw new \InvalidArgumentException('non-nullable country cannot be null'); + } + $this->container['country'] = $country; + + return $this; + } + + /** + * Gets city + * + * @return string|null + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string|null $city Город. + * + * @return self + */ + public function setCity($city) + { + if (is_null($city)) { + throw new \InvalidArgumentException('non-nullable city cannot be null'); + } + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets street + * + * @return string|null + */ + public function getStreet() + { + return $this->container['street']; + } + + /** + * Sets street + * + * @param string|null $street Улица. + * + * @return self + */ + public function setStreet($street) + { + if (is_null($street)) { + throw new \InvalidArgumentException('non-nullable street cannot be null'); + } + $this->container['street'] = $street; + + return $this; + } + + /** + * Gets house + * + * @return string|null + */ + public function getHouse() + { + return $this->container['house']; + } + + /** + * Sets house + * + * @param string|null $house Номер дома. + * + * @return self + */ + public function setHouse($house) + { + if (is_null($house)) { + throw new \InvalidArgumentException('non-nullable house cannot be null'); + } + $this->container['house'] = $house; + + return $this; + } + + /** + * Gets postcode + * + * @return string|null + */ + public function getPostcode() + { + return $this->container['postcode']; + } + + /** + * Sets postcode + * + * @param string|null $postcode Почтовый индекс. + * + * @return self + */ + public function setPostcode($postcode) + { + if (is_null($postcode)) { + throw new \InvalidArgumentException('non-nullable postcode cannot be null'); + } + $this->container['postcode'] = $postcode; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PlacementType.php b/erp24/lib/yandex_market_api/Model/PlacementType.php new file mode 100644 index 00000000..0c74adcc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PlacementType.php @@ -0,0 +1,66 @@ + + */ +class PriceCompetitivenessThresholdsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PriceCompetitivenessThresholdsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'optimal_price' => '\OpenAPI\Client\Model\BasePriceDTO', + 'average_price' => '\OpenAPI\Client\Model\BasePriceDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'optimal_price' => null, + 'average_price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'optimal_price' => false, + 'average_price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'optimal_price' => 'optimalPrice', + 'average_price' => 'averagePrice' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'optimal_price' => 'setOptimalPrice', + 'average_price' => 'setAveragePrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'optimal_price' => 'getOptimalPrice', + 'average_price' => 'getAveragePrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('optimal_price', $data ?? [], null); + $this->setIfExists('average_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets optimal_price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getOptimalPrice() + { + return $this->container['optimal_price']; + } + + /** + * Sets optimal_price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $optimal_price optimal_price + * + * @return self + */ + public function setOptimalPrice($optimal_price) + { + if (is_null($optimal_price)) { + throw new \InvalidArgumentException('non-nullable optimal_price cannot be null'); + } + $this->container['optimal_price'] = $optimal_price; + + return $this; + } + + /** + * Gets average_price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getAveragePrice() + { + return $this->container['average_price']; + } + + /** + * Sets average_price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $average_price average_price + * + * @return self + */ + public function setAveragePrice($average_price) + { + if (is_null($average_price)) { + throw new \InvalidArgumentException('non-nullable average_price cannot be null'); + } + $this->container['average_price'] = $average_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PriceCompetitivenessType.php b/erp24/lib/yandex_market_api/Model/PriceCompetitivenessType.php new file mode 100644 index 00000000..b7b48160 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PriceCompetitivenessType.php @@ -0,0 +1,66 @@ + + */ +class PriceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PriceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'float', + 'discount_base' => 'float', + 'currency_id' => '\OpenAPI\Client\Model\CurrencyType', + 'vat' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'discount_base' => null, + 'currency_id' => null, + 'vat' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'value' => false, + 'discount_base' => false, + 'currency_id' => false, + 'vat' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'discount_base' => 'discountBase', + 'currency_id' => 'currencyId', + 'vat' => 'vat' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'discount_base' => 'setDiscountBase', + 'currency_id' => 'setCurrencyId', + 'vat' => 'setVat' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'discount_base' => 'getDiscountBase', + 'currency_id' => 'getCurrencyId', + 'vat' => 'getVat' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('discount_base', $data ?? [], null); + $this->setIfExists('currency_id', $data ?? [], null); + $this->setIfExists('vat', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return float|null + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param float|null $value Цена на товар. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets discount_base + * + * @return float|null + */ + public function getDiscountBase() + { + return $this->container['discount_base']; + } + + /** + * Sets discount_base + * + * @param float|null $discount_base Цена на товар без скидки. Число должно быть целым. Вы можете указать цену со скидкой от 5 до 99%. Передавайте этот параметр при каждом обновлении цены, если предоставляете скидку на товар. + * + * @return self + */ + public function setDiscountBase($discount_base) + { + if (is_null($discount_base)) { + throw new \InvalidArgumentException('non-nullable discount_base cannot be null'); + } + $this->container['discount_base'] = $discount_base; + + return $this; + } + + /** + * Gets currency_id + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrencyId() + { + return $this->container['currency_id']; + } + + /** + * Sets currency_id + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency_id currency_id + * + * @return self + */ + public function setCurrencyId($currency_id) + { + if (is_null($currency_id)) { + throw new \InvalidArgumentException('non-nullable currency_id cannot be null'); + } + $this->container['currency_id'] = $currency_id; + + return $this; + } + + /** + * Gets vat + * + * @return int|null + */ + public function getVat() + { + return $this->container['vat']; + } + + /** + * Sets vat + * + * @param int|null $vat Идентификатор ставки НДС, применяемой для товара: * `2` — 10%. * `5` — 0%. * `6` — не облагается НДС. * `7` — 20%. Если параметр не указан, используется ставка НДС, установленная в кабинете. + * + * @return self + */ + public function setVat($vat) + { + if (is_null($vat)) { + throw new \InvalidArgumentException('non-nullable vat cannot be null'); + } + $this->container['vat'] = $vat; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictDTO.php b/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictDTO.php new file mode 100644 index 00000000..d2170828 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictDTO.php @@ -0,0 +1,447 @@ + + */ +class PriceQuarantineVerdictDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PriceQuarantineVerdictDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\PriceQuarantineVerdictType', + 'params' => '\OpenAPI\Client\Model\PriceQuarantineVerdictParameterDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'params' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'params' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'params' => 'params' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'params' => 'setParams' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'params' => 'getParams' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('params', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['params'] === null) { + $invalidProperties[] = "'params' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\PriceQuarantineVerdictType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\PriceQuarantineVerdictType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets params + * + * @return \OpenAPI\Client\Model\PriceQuarantineVerdictParameterDTO[] + */ + public function getParams() + { + return $this->container['params']; + } + + /** + * Sets params + * + * @param \OpenAPI\Client\Model\PriceQuarantineVerdictParameterDTO[] $params Цена, из-за которой товар попал в карантин, и значения для сравнения. Конкретный набор параметров зависит от типа карантина. + * + * @return self + */ + public function setParams($params) + { + if (is_null($params)) { + throw new \InvalidArgumentException('non-nullable params cannot be null'); + } + $this->container['params'] = $params; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictParamNameType.php b/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictParamNameType.php new file mode 100644 index 00000000..74c38de1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictParamNameType.php @@ -0,0 +1,69 @@ + + */ +class PriceQuarantineVerdictParameterDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PriceQuarantineVerdictParameterDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => '\OpenAPI\Client\Model\PriceQuarantineVerdictParamNameType', + 'value' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'value' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'value' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('value', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return \OpenAPI\Client\Model\PriceQuarantineVerdictParamNameType + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param \OpenAPI\Client\Model\PriceQuarantineVerdictParamNameType $name name + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value Значение параметра. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictType.php b/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictType.php new file mode 100644 index 00000000..3dff9563 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PriceQuarantineVerdictType.php @@ -0,0 +1,66 @@ + + */ +class PriceRecommendationItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PriceRecommendationItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_id' => 'int', + 'price' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_id' => 'int64', + 'price' => 'decimal' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_id' => false, + 'price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_id' => 'campaignId', + 'price' => 'price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_id' => 'setCampaignId', + 'price' => 'setPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_id' => 'getCampaignId', + 'price' => 'getPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + if ($this->container['price'] === null) { + $invalidProperties[] = "'price' can't be null"; + } + if (($this->container['price'] < 1)) { + $invalidProperties[] = "invalid value for 'price', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор кампании. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets price + * + * @return float + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float $price Рекомендованная цена на товар. Чтобы продвижение хорошо работало, цена на товар должна быть не выше этого значения. [Подробно о рекомендованных ценах](https://yandex.ru/support/marketplace/marketing/campaigns.html#prices) + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + + if (($price < 1)) { + throw new \InvalidArgumentException('invalid value for $price when calling PriceRecommendationItemDTO., must be bigger than or equal to 1.'); + } + + $this->container['price'] = $price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PriceSuggestDTO.php b/erp24/lib/yandex_market_api/Model/PriceSuggestDTO.php new file mode 100644 index 00000000..eeaef213 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PriceSuggestDTO.php @@ -0,0 +1,444 @@ + + */ +class PriceSuggestDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PriceSuggestDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\PriceSuggestType', + 'price' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'price' => 'price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'price' => 'setPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'price' => 'getPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\PriceSuggestType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\PriceSuggestType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets price + * + * @return float|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param float|null $price Цена в рублях. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PriceSuggestOfferDTO.php b/erp24/lib/yandex_market_api/Model/PriceSuggestOfferDTO.php new file mode 100644 index 00000000..74e38601 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PriceSuggestOfferDTO.php @@ -0,0 +1,516 @@ + + */ +class PriceSuggestOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PriceSuggestOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'market_sku' => 'int', + 'offer_id' => 'string', + 'price_suggestion' => '\OpenAPI\Client\Model\PriceSuggestDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'market_sku' => 'int64', + 'offer_id' => null, + 'price_suggestion' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'market_sku' => false, + 'offer_id' => false, + 'price_suggestion' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'market_sku' => 'marketSku', + 'offer_id' => 'offerId', + 'price_suggestion' => 'priceSuggestion' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'market_sku' => 'setMarketSku', + 'offer_id' => 'setOfferId', + 'price_suggestion' => 'setPriceSuggestion' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'market_sku' => 'getMarketSku', + 'offer_id' => 'getOfferId', + 'price_suggestion' => 'getPriceSuggestion' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('market_sku', $data ?? [], null); + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('price_suggestion', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling PriceSuggestOfferDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling PriceSuggestOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling PriceSuggestOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling PriceSuggestOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets price_suggestion + * + * @return \OpenAPI\Client\Model\PriceSuggestDTO[]|null + */ + public function getPriceSuggestion() + { + return $this->container['price_suggestion']; + } + + /** + * Sets price_suggestion + * + * @param \OpenAPI\Client\Model\PriceSuggestDTO[]|null $price_suggestion Цены для продвижения. + * + * @return self + */ + public function setPriceSuggestion($price_suggestion) + { + if (is_null($price_suggestion)) { + array_push($this->openAPINullablesSetToNull, 'price_suggestion'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('price_suggestion', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['price_suggestion'] = $price_suggestion; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PriceSuggestType.php b/erp24/lib/yandex_market_api/Model/PriceSuggestType.php new file mode 100644 index 00000000..167ec99a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PriceSuggestType.php @@ -0,0 +1,66 @@ + + */ +class PromoOfferAutoParticipatingDetailsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PromoOfferAutoParticipatingDetailsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'campaign_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'campaign_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'campaign_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'campaign_ids' => 'campaignIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'campaign_ids' => 'setCampaignIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'campaign_ids' => 'getCampaignIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('campaign_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets campaign_ids + * + * @return int[]|null + */ + public function getCampaignIds() + { + return $this->container['campaign_ids']; + } + + /** + * Sets campaign_ids + * + * @param int[]|null $campaign_ids Магазины, в которых товар добавлен в акцию автоматически. Возвращается, если статус товара в акции — `PARTIALLY_AUTO`. + * + * @return self + */ + public function setCampaignIds($campaign_ids) + { + if (is_null($campaign_ids)) { + array_push($this->openAPINullablesSetToNull, 'campaign_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('campaign_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['campaign_ids'] = $campaign_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PromoOfferDiscountParamsDTO.php b/erp24/lib/yandex_market_api/Model/PromoOfferDiscountParamsDTO.php new file mode 100644 index 00000000..4029ab11 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PromoOfferDiscountParamsDTO.php @@ -0,0 +1,481 @@ + + */ +class PromoOfferDiscountParamsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PromoOfferDiscountParamsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'price' => 'int', + 'promo_price' => 'int', + 'max_promo_price' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'price' => 'int64', + 'promo_price' => 'int64', + 'max_promo_price' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'price' => false, + 'promo_price' => false, + 'max_promo_price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'price' => 'price', + 'promo_price' => 'promoPrice', + 'max_promo_price' => 'maxPromoPrice' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'price' => 'setPrice', + 'promo_price' => 'setPromoPrice', + 'max_promo_price' => 'setMaxPromoPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'price' => 'getPrice', + 'promo_price' => 'getPromoPrice', + 'max_promo_price' => 'getMaxPromoPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('promo_price', $data ?? [], null); + $this->setIfExists('max_promo_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['max_promo_price'] === null) { + $invalidProperties[] = "'max_promo_price' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets price + * + * @return int|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param int|null $price Зачеркнутая цена — та, по которой товар продавался до акции. Указывается в рублях. Возвращается, только если товар участвует в акции. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets promo_price + * + * @return int|null + */ + public function getPromoPrice() + { + return $this->container['promo_price']; + } + + /** + * Sets promo_price + * + * @param int|null $promo_price Цена по акции — та, по которой вы хотите продавать товар. Указывается в рублях. Возвращается, только если товар участвует в акции. + * + * @return self + */ + public function setPromoPrice($promo_price) + { + if (is_null($promo_price)) { + throw new \InvalidArgumentException('non-nullable promo_price cannot be null'); + } + $this->container['promo_price'] = $promo_price; + + return $this; + } + + /** + * Gets max_promo_price + * + * @return int + */ + public function getMaxPromoPrice() + { + return $this->container['max_promo_price']; + } + + /** + * Sets max_promo_price + * + * @param int $max_promo_price Максимально возможная цена для участия в акции. Указывается в рублях. Возвращается для всех товаров. + * + * @return self + */ + public function setMaxPromoPrice($max_promo_price) + { + if (is_null($max_promo_price)) { + throw new \InvalidArgumentException('non-nullable max_promo_price cannot be null'); + } + $this->container['max_promo_price'] = $max_promo_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PromoOfferParamsDTO.php b/erp24/lib/yandex_market_api/Model/PromoOfferParamsDTO.php new file mode 100644 index 00000000..c23eef69 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PromoOfferParamsDTO.php @@ -0,0 +1,444 @@ + + */ +class PromoOfferParamsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PromoOfferParamsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'discount_params' => '\OpenAPI\Client\Model\PromoOfferDiscountParamsDTO', + 'promocode_params' => '\OpenAPI\Client\Model\PromoOfferPromocodeParamsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'discount_params' => null, + 'promocode_params' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'discount_params' => false, + 'promocode_params' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'discount_params' => 'discountParams', + 'promocode_params' => 'promocodeParams' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'discount_params' => 'setDiscountParams', + 'promocode_params' => 'setPromocodeParams' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'discount_params' => 'getDiscountParams', + 'promocode_params' => 'getPromocodeParams' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('discount_params', $data ?? [], null); + $this->setIfExists('promocode_params', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets discount_params + * + * @return \OpenAPI\Client\Model\PromoOfferDiscountParamsDTO|null + */ + public function getDiscountParams() + { + return $this->container['discount_params']; + } + + /** + * Sets discount_params + * + * @param \OpenAPI\Client\Model\PromoOfferDiscountParamsDTO|null $discount_params discount_params + * + * @return self + */ + public function setDiscountParams($discount_params) + { + if (is_null($discount_params)) { + throw new \InvalidArgumentException('non-nullable discount_params cannot be null'); + } + $this->container['discount_params'] = $discount_params; + + return $this; + } + + /** + * Gets promocode_params + * + * @return \OpenAPI\Client\Model\PromoOfferPromocodeParamsDTO|null + */ + public function getPromocodeParams() + { + return $this->container['promocode_params']; + } + + /** + * Sets promocode_params + * + * @param \OpenAPI\Client\Model\PromoOfferPromocodeParamsDTO|null $promocode_params promocode_params + * + * @return self + */ + public function setPromocodeParams($promocode_params) + { + if (is_null($promocode_params)) { + throw new \InvalidArgumentException('non-nullable promocode_params cannot be null'); + } + $this->container['promocode_params'] = $promocode_params; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PromoOfferParticipationStatusFilterType.php b/erp24/lib/yandex_market_api/Model/PromoOfferParticipationStatusFilterType.php new file mode 100644 index 00000000..a8563aab --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PromoOfferParticipationStatusFilterType.php @@ -0,0 +1,63 @@ + + */ +class PromoOfferPromocodeParamsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PromoOfferPromocodeParamsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'max_price' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'max_price' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'max_price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'max_price' => 'maxPrice' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'max_price' => 'setMaxPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'max_price' => 'getMaxPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('max_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['max_price'] === null) { + $invalidProperties[] = "'max_price' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets max_price + * + * @return int + */ + public function getMaxPrice() + { + return $this->container['max_price']; + } + + /** + * Sets max_price + * + * @param int $max_price Максимально возможная цена для участия в акции до применения промокода. Указывается в рублях. Возвращается для всех товаров. + * + * @return self + */ + public function setMaxPrice($max_price) + { + if (is_null($max_price)) { + throw new \InvalidArgumentException('non-nullable max_price cannot be null'); + } + $this->container['max_price'] = $max_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PromoOfferUpdateWarningCodeType.php b/erp24/lib/yandex_market_api/Model/PromoOfferUpdateWarningCodeType.php new file mode 100644 index 00000000..5177ee95 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PromoOfferUpdateWarningCodeType.php @@ -0,0 +1,72 @@ + + */ +class PromoOfferUpdateWarningDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PromoOfferUpdateWarningDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'code' => '\OpenAPI\Client\Model\PromoOfferUpdateWarningCodeType', + 'campaign_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'code' => null, + 'campaign_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'code' => false, + 'campaign_ids' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'code' => 'code', + 'campaign_ids' => 'campaignIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'code' => 'setCode', + 'campaign_ids' => 'setCampaignIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'code' => 'getCode', + 'campaign_ids' => 'getCampaignIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('code', $data ?? [], null); + $this->setIfExists('campaign_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['code'] === null) { + $invalidProperties[] = "'code' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets code + * + * @return \OpenAPI\Client\Model\PromoOfferUpdateWarningCodeType + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param \OpenAPI\Client\Model\PromoOfferUpdateWarningCodeType $code code + * + * @return self + */ + public function setCode($code) + { + if (is_null($code)) { + throw new \InvalidArgumentException('non-nullable code cannot be null'); + } + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets campaign_ids + * + * @return int[]|null + */ + public function getCampaignIds() + { + return $this->container['campaign_ids']; + } + + /** + * Sets campaign_ids + * + * @param int[]|null $campaign_ids Идентификаторы магазинов в кабинете, для которых получены предупреждения. Не возвращается, если предупреждения действуют для всех магазинов в кабинете. + * + * @return self + */ + public function setCampaignIds($campaign_ids) + { + if (is_null($campaign_ids)) { + array_push($this->openAPINullablesSetToNull, 'campaign_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('campaign_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['campaign_ids'] = $campaign_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PromoParticipationType.php b/erp24/lib/yandex_market_api/Model/PromoParticipationType.php new file mode 100644 index 00000000..f038333d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PromoParticipationType.php @@ -0,0 +1,63 @@ + + */ +class PromoPeriodDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PromoPeriodDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'date_time_from' => '\DateTime', + 'date_time_to' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'date_time_from' => 'date-time', + 'date_time_to' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'date_time_from' => false, + 'date_time_to' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'date_time_from' => 'dateTimeFrom', + 'date_time_to' => 'dateTimeTo' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'date_time_from' => 'setDateTimeFrom', + 'date_time_to' => 'setDateTimeTo' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'date_time_from' => 'getDateTimeFrom', + 'date_time_to' => 'getDateTimeTo' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('date_time_from', $data ?? [], null); + $this->setIfExists('date_time_to', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['date_time_from'] === null) { + $invalidProperties[] = "'date_time_from' can't be null"; + } + if ($this->container['date_time_to'] === null) { + $invalidProperties[] = "'date_time_to' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets date_time_from + * + * @return \DateTime + */ + public function getDateTimeFrom() + { + return $this->container['date_time_from']; + } + + /** + * Sets date_time_from + * + * @param \DateTime $date_time_from Дата и время начала акции. + * + * @return self + */ + public function setDateTimeFrom($date_time_from) + { + if (is_null($date_time_from)) { + throw new \InvalidArgumentException('non-nullable date_time_from cannot be null'); + } + $this->container['date_time_from'] = $date_time_from; + + return $this; + } + + /** + * Gets date_time_to + * + * @return \DateTime + */ + public function getDateTimeTo() + { + return $this->container['date_time_to']; + } + + /** + * Sets date_time_to + * + * @param \DateTime $date_time_to Дата и время окончания акции. + * + * @return self + */ + public function setDateTimeTo($date_time_to) + { + if (is_null($date_time_to)) { + throw new \InvalidArgumentException('non-nullable date_time_to cannot be null'); + } + $this->container['date_time_to'] = $date_time_to; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ProvideOrderDigitalCodesRequest.php b/erp24/lib/yandex_market_api/Model/ProvideOrderDigitalCodesRequest.php new file mode 100644 index 00000000..f51033b8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ProvideOrderDigitalCodesRequest.php @@ -0,0 +1,413 @@ + + */ +class ProvideOrderDigitalCodesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ProvideOrderDigitalCodesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\OpenAPI\Client\Model\OrderDigitalItemDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'items' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('items', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\OrderDigitalItemDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\OrderDigitalItemDTO[] $items Список проданных ключей. Если в заказе есть несколько **одинаковых** товаров (например, несколько ключей к одной и той же подписке), передайте каждый в виде отдельного элемента массива. `id` у этих элементов должен быть один и тот же. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ProvideOrderItemIdentifiersRequest.php b/erp24/lib/yandex_market_api/Model/ProvideOrderItemIdentifiersRequest.php new file mode 100644 index 00000000..9ad166b1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ProvideOrderItemIdentifiersRequest.php @@ -0,0 +1,412 @@ + + */ +class ProvideOrderItemIdentifiersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ProvideOrderItemIdentifiersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\OpenAPI\Client\Model\OrderItemInstanceModificationDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'items' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('items', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\OrderItemInstanceModificationDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\OrderItemInstanceModificationDTO[] $items Список позиций, требующих маркировки. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ProvideOrderItemIdentifiersResponse.php b/erp24/lib/yandex_market_api/Model/ProvideOrderItemIdentifiersResponse.php new file mode 100644 index 00000000..24f7a1e6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ProvideOrderItemIdentifiersResponse.php @@ -0,0 +1,443 @@ + + */ +class ProvideOrderItemIdentifiersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ProvideOrderItemIdentifiersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OrderItemsModificationResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OrderItemsModificationResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OrderItemsModificationResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/PutSkuBidsRequest.php b/erp24/lib/yandex_market_api/Model/PutSkuBidsRequest.php new file mode 100644 index 00000000..4208568c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/PutSkuBidsRequest.php @@ -0,0 +1,428 @@ + + */ +class PutSkuBidsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'PutSkuBidsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'bids' => '\OpenAPI\Client\Model\SkuBidItemDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'bids' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'bids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'bids' => 'bids' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'bids' => 'setBids' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'bids' => 'getBids' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('bids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['bids'] === null) { + $invalidProperties[] = "'bids' can't be null"; + } + if ((count($this->container['bids']) > 1500)) { + $invalidProperties[] = "invalid value for 'bids', number of items must be less than or equal to 1500."; + } + + if ((count($this->container['bids']) < 1)) { + $invalidProperties[] = "invalid value for 'bids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets bids + * + * @return \OpenAPI\Client\Model\SkuBidItemDTO[] + */ + public function getBids() + { + return $this->container['bids']; + } + + /** + * Sets bids + * + * @param \OpenAPI\Client\Model\SkuBidItemDTO[] $bids Список товаров и ставки для продвижения, которые на них нужно установить. + * + * @return self + */ + public function setBids($bids) + { + if (is_null($bids)) { + throw new \InvalidArgumentException('non-nullable bids cannot be null'); + } + + if ((count($bids) > 1500)) { + throw new \InvalidArgumentException('invalid value for $bids when calling PutSkuBidsRequest., number of items must be less than or equal to 1500.'); + } + if ((count($bids) < 1)) { + throw new \InvalidArgumentException('invalid length for $bids when calling PutSkuBidsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['bids'] = $bids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/QualityRatingAffectedOrderDTO.php b/erp24/lib/yandex_market_api/Model/QualityRatingAffectedOrderDTO.php new file mode 100644 index 00000000..9ea9c6f1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/QualityRatingAffectedOrderDTO.php @@ -0,0 +1,496 @@ + + */ +class QualityRatingAffectedOrderDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'QualityRatingAffectedOrderDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order_id' => 'int', + 'description' => 'string', + 'component_type' => '\OpenAPI\Client\Model\AffectedOrderQualityRatingComponentType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order_id' => 'int64', + 'description' => null, + 'component_type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order_id' => false, + 'description' => false, + 'component_type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order_id' => 'orderId', + 'description' => 'description', + 'component_type' => 'componentType' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order_id' => 'setOrderId', + 'description' => 'setDescription', + 'component_type' => 'setComponentType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order_id' => 'getOrderId', + 'description' => 'getDescription', + 'component_type' => 'getComponentType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order_id', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('component_type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['order_id'] === null) { + $invalidProperties[] = "'order_id' can't be null"; + } + if (($this->container['order_id'] < 0)) { + $invalidProperties[] = "invalid value for 'order_id', must be bigger than or equal to 0."; + } + + if ($this->container['description'] === null) { + $invalidProperties[] = "'description' can't be null"; + } + if ($this->container['component_type'] === null) { + $invalidProperties[] = "'component_type' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order_id + * + * @return int + */ + public function getOrderId() + { + return $this->container['order_id']; + } + + /** + * Sets order_id + * + * @param int $order_id Идентификатор заказа. + * + * @return self + */ + public function setOrderId($order_id) + { + if (is_null($order_id)) { + throw new \InvalidArgumentException('non-nullable order_id cannot be null'); + } + + if (($order_id < 0)) { + throw new \InvalidArgumentException('invalid value for $order_id when calling QualityRatingAffectedOrderDTO., must be bigger than or equal to 0.'); + } + + $this->container['order_id'] = $order_id; + + return $this; + } + + /** + * Gets description + * + * @return string + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string $description Описание проблемы. + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets component_type + * + * @return \OpenAPI\Client\Model\AffectedOrderQualityRatingComponentType + */ + public function getComponentType() + { + return $this->container['component_type']; + } + + /** + * Sets component_type + * + * @param \OpenAPI\Client\Model\AffectedOrderQualityRatingComponentType $component_type component_type + * + * @return self + */ + public function setComponentType($component_type) + { + if (is_null($component_type)) { + throw new \InvalidArgumentException('non-nullable component_type cannot be null'); + } + $this->container['component_type'] = $component_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/QualityRatingComponentDTO.php b/erp24/lib/yandex_market_api/Model/QualityRatingComponentDTO.php new file mode 100644 index 00000000..4d75c250 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/QualityRatingComponentDTO.php @@ -0,0 +1,466 @@ + + */ +class QualityRatingComponentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'QualityRatingComponentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'float', + 'component_type' => '\OpenAPI\Client\Model\QualityRatingComponentType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => 'double', + 'component_type' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'value' => false, + 'component_type' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'component_type' => 'componentType' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'component_type' => 'setComponentType' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'component_type' => 'getComponentType' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('component_type', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if (($this->container['value'] > 100)) { + $invalidProperties[] = "invalid value for 'value', must be smaller than or equal to 100."; + } + + if (($this->container['value'] < 0)) { + $invalidProperties[] = "invalid value for 'value', must be bigger than or equal to 0."; + } + + if ($this->container['component_type'] === null) { + $invalidProperties[] = "'component_type' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return float + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param float $value Значение составляющей в процентах. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + + if (($value > 100)) { + throw new \InvalidArgumentException('invalid value for $value when calling QualityRatingComponentDTO., must be smaller than or equal to 100.'); + } + if (($value < 0)) { + throw new \InvalidArgumentException('invalid value for $value when calling QualityRatingComponentDTO., must be bigger than or equal to 0.'); + } + + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets component_type + * + * @return \OpenAPI\Client\Model\QualityRatingComponentType + */ + public function getComponentType() + { + return $this->container['component_type']; + } + + /** + * Sets component_type + * + * @param \OpenAPI\Client\Model\QualityRatingComponentType $component_type component_type + * + * @return self + */ + public function setComponentType($component_type) + { + if (is_null($component_type)) { + throw new \InvalidArgumentException('non-nullable component_type cannot be null'); + } + $this->container['component_type'] = $component_type; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/QualityRatingComponentType.php b/erp24/lib/yandex_market_api/Model/QualityRatingComponentType.php new file mode 100644 index 00000000..99bd7881 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/QualityRatingComponentType.php @@ -0,0 +1,81 @@ + + */ +class QualityRatingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'QualityRatingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rating' => 'int', + 'calculation_date' => '\DateTime', + 'components' => '\OpenAPI\Client\Model\QualityRatingComponentDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rating' => 'int64', + 'calculation_date' => 'date', + 'components' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rating' => false, + 'calculation_date' => false, + 'components' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rating' => 'rating', + 'calculation_date' => 'calculationDate', + 'components' => 'components' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rating' => 'setRating', + 'calculation_date' => 'setCalculationDate', + 'components' => 'setComponents' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rating' => 'getRating', + 'calculation_date' => 'getCalculationDate', + 'components' => 'getComponents' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('rating', $data ?? [], null); + $this->setIfExists('calculation_date', $data ?? [], null); + $this->setIfExists('components', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['rating'] === null) { + $invalidProperties[] = "'rating' can't be null"; + } + if (($this->container['rating'] > 100)) { + $invalidProperties[] = "invalid value for 'rating', must be smaller than or equal to 100."; + } + + if (($this->container['rating'] < 0)) { + $invalidProperties[] = "invalid value for 'rating', must be bigger than or equal to 0."; + } + + if ($this->container['calculation_date'] === null) { + $invalidProperties[] = "'calculation_date' can't be null"; + } + if ($this->container['components'] === null) { + $invalidProperties[] = "'components' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets rating + * + * @return int + */ + public function getRating() + { + return $this->container['rating']; + } + + /** + * Sets rating + * + * @param int $rating Значение индекса качества. + * + * @return self + */ + public function setRating($rating) + { + if (is_null($rating)) { + throw new \InvalidArgumentException('non-nullable rating cannot be null'); + } + + if (($rating > 100)) { + throw new \InvalidArgumentException('invalid value for $rating when calling QualityRatingDTO., must be smaller than or equal to 100.'); + } + if (($rating < 0)) { + throw new \InvalidArgumentException('invalid value for $rating when calling QualityRatingDTO., must be bigger than or equal to 0.'); + } + + $this->container['rating'] = $rating; + + return $this; + } + + /** + * Gets calculation_date + * + * @return \DateTime + */ + public function getCalculationDate() + { + return $this->container['calculation_date']; + } + + /** + * Sets calculation_date + * + * @param \DateTime $calculation_date Дата вычисления. Формат даты: `ГГГГ‑ММ‑ДД`. + * + * @return self + */ + public function setCalculationDate($calculation_date) + { + if (is_null($calculation_date)) { + throw new \InvalidArgumentException('non-nullable calculation_date cannot be null'); + } + $this->container['calculation_date'] = $calculation_date; + + return $this; + } + + /** + * Gets components + * + * @return \OpenAPI\Client\Model\QualityRatingComponentDTO[] + */ + public function getComponents() + { + return $this->container['components']; + } + + /** + * Sets components + * + * @param \OpenAPI\Client\Model\QualityRatingComponentDTO[] $components Составляющие индекса качества. + * + * @return self + */ + public function setComponents($components) + { + if (is_null($components)) { + throw new \InvalidArgumentException('non-nullable components cannot be null'); + } + $this->container['components'] = $components; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/QualityRatingDetailsDTO.php b/erp24/lib/yandex_market_api/Model/QualityRatingDetailsDTO.php new file mode 100644 index 00000000..13997cc7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/QualityRatingDetailsDTO.php @@ -0,0 +1,413 @@ + + */ +class QualityRatingDetailsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'QualityRatingDetailsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'affected_orders' => '\OpenAPI\Client\Model\QualityRatingAffectedOrderDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'affected_orders' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'affected_orders' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'affected_orders' => 'affectedOrders' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'affected_orders' => 'setAffectedOrders' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'affected_orders' => 'getAffectedOrders' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('affected_orders', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['affected_orders'] === null) { + $invalidProperties[] = "'affected_orders' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets affected_orders + * + * @return \OpenAPI\Client\Model\QualityRatingAffectedOrderDTO[] + */ + public function getAffectedOrders() + { + return $this->container['affected_orders']; + } + + /** + * Sets affected_orders + * + * @param \OpenAPI\Client\Model\QualityRatingAffectedOrderDTO[] $affected_orders Список заказов, которые повлияли на индекс качества. + * + * @return self + */ + public function setAffectedOrders($affected_orders) + { + if (is_null($affected_orders)) { + throw new \InvalidArgumentException('non-nullable affected_orders cannot be null'); + } + $this->container['affected_orders'] = $affected_orders; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/QuantumDTO.php b/erp24/lib/yandex_market_api/Model/QuantumDTO.php new file mode 100644 index 00000000..4bea853a --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/QuantumDTO.php @@ -0,0 +1,469 @@ + + */ +class QuantumDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'QuantumDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'min_quantity' => 'int', + 'step_quantity' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'min_quantity' => 'int32', + 'step_quantity' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'min_quantity' => false, + 'step_quantity' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'min_quantity' => 'minQuantity', + 'step_quantity' => 'stepQuantity' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'min_quantity' => 'setMinQuantity', + 'step_quantity' => 'setStepQuantity' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'min_quantity' => 'getMinQuantity', + 'step_quantity' => 'getStepQuantity' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('min_quantity', $data ?? [], null); + $this->setIfExists('step_quantity', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['min_quantity']) && ($this->container['min_quantity'] < 1)) { + $invalidProperties[] = "invalid value for 'min_quantity', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['step_quantity']) && ($this->container['step_quantity'] > 100)) { + $invalidProperties[] = "invalid value for 'step_quantity', must be smaller than or equal to 100."; + } + + if (!is_null($this->container['step_quantity']) && ($this->container['step_quantity'] < 1)) { + $invalidProperties[] = "invalid value for 'step_quantity', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets min_quantity + * + * @return int|null + */ + public function getMinQuantity() + { + return $this->container['min_quantity']; + } + + /** + * Sets min_quantity + * + * @param int|null $min_quantity Минимальное количество единиц товара в заказе. Например, если указать 10, покупатель сможет добавить в корзину не меньше 10 единиц. ⚠️ Если количество товара на складе меньше заданного, ограничение не сработает и покупатель сможет его заказать. + * + * @return self + */ + public function setMinQuantity($min_quantity) + { + if (is_null($min_quantity)) { + throw new \InvalidArgumentException('non-nullable min_quantity cannot be null'); + } + + if (($min_quantity < 1)) { + throw new \InvalidArgumentException('invalid value for $min_quantity when calling QuantumDTO., must be bigger than or equal to 1.'); + } + + $this->container['min_quantity'] = $min_quantity; + + return $this; + } + + /** + * Gets step_quantity + * + * @return int|null + */ + public function getStepQuantity() + { + return $this->container['step_quantity']; + } + + /** + * Sets step_quantity + * + * @param int|null $step_quantity На сколько единиц покупатель сможет увеличить количество товара в корзине. Например, если задать 5, покупатель сможет добавить к заказу только 5, 10, 15, ... единиц товара. ⚠️ Если количество товара на складе не дотягивает до кванта, ограничение не сработает и покупатель сможет заказать количество, не кратное кванту. + * + * @return self + */ + public function setStepQuantity($step_quantity) + { + if (is_null($step_quantity)) { + throw new \InvalidArgumentException('non-nullable step_quantity cannot be null'); + } + + if (($step_quantity > 100)) { + throw new \InvalidArgumentException('invalid value for $step_quantity when calling QuantumDTO., must be smaller than or equal to 100.'); + } + if (($step_quantity < 1)) { + throw new \InvalidArgumentException('invalid value for $step_quantity when calling QuantumDTO., must be bigger than or equal to 1.'); + } + + $this->container['step_quantity'] = $step_quantity; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/QuarantineOfferDTO.php b/erp24/lib/yandex_market_api/Model/QuarantineOfferDTO.php new file mode 100644 index 00000000..0440447c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/QuarantineOfferDTO.php @@ -0,0 +1,541 @@ + + */ +class QuarantineOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'QuarantineOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'current_price' => '\OpenAPI\Client\Model\BasePriceDTO', + 'last_valid_price' => '\OpenAPI\Client\Model\BasePriceDTO', + 'verdicts' => '\OpenAPI\Client\Model\PriceQuarantineVerdictDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'current_price' => null, + 'last_valid_price' => null, + 'verdicts' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'current_price' => false, + 'last_valid_price' => false, + 'verdicts' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'current_price' => 'currentPrice', + 'last_valid_price' => 'lastValidPrice', + 'verdicts' => 'verdicts' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'current_price' => 'setCurrentPrice', + 'last_valid_price' => 'setLastValidPrice', + 'verdicts' => 'setVerdicts' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'current_price' => 'getCurrentPrice', + 'last_valid_price' => 'getLastValidPrice', + 'verdicts' => 'getVerdicts' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('current_price', $data ?? [], null); + $this->setIfExists('last_valid_price', $data ?? [], null); + $this->setIfExists('verdicts', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling QuarantineOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling QuarantineOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling QuarantineOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets current_price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getCurrentPrice() + { + return $this->container['current_price']; + } + + /** + * Sets current_price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $current_price current_price + * + * @return self + */ + public function setCurrentPrice($current_price) + { + if (is_null($current_price)) { + throw new \InvalidArgumentException('non-nullable current_price cannot be null'); + } + $this->container['current_price'] = $current_price; + + return $this; + } + + /** + * Gets last_valid_price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getLastValidPrice() + { + return $this->container['last_valid_price']; + } + + /** + * Sets last_valid_price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $last_valid_price last_valid_price + * + * @return self + */ + public function setLastValidPrice($last_valid_price) + { + if (is_null($last_valid_price)) { + throw new \InvalidArgumentException('non-nullable last_valid_price cannot be null'); + } + $this->container['last_valid_price'] = $last_valid_price; + + return $this; + } + + /** + * Gets verdicts + * + * @return \OpenAPI\Client\Model\PriceQuarantineVerdictDTO[]|null + */ + public function getVerdicts() + { + return $this->container['verdicts']; + } + + /** + * Sets verdicts + * + * @param \OpenAPI\Client\Model\PriceQuarantineVerdictDTO[]|null $verdicts Причины попадания товара в карантин. + * + * @return self + */ + public function setVerdicts($verdicts) + { + if (is_null($verdicts)) { + array_push($this->openAPINullablesSetToNull, 'verdicts'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('verdicts', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['verdicts'] = $verdicts; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/RecipientType.php b/erp24/lib/yandex_market_api/Model/RecipientType.php new file mode 100644 index 00000000..860bf126 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/RecipientType.php @@ -0,0 +1,66 @@ + + */ +class RegionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RegionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'type' => '\OpenAPI\Client\Model\RegionType', + 'parent' => '\OpenAPI\Client\Model\RegionDTO', + 'children' => '\OpenAPI\Client\Model\RegionDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'type' => null, + 'parent' => null, + 'children' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'type' => false, + 'parent' => false, + 'children' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'type' => 'type', + 'parent' => 'parent', + 'children' => 'children' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'type' => 'setType', + 'parent' => 'setParent', + 'children' => 'setChildren' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'type' => 'getType', + 'parent' => 'getParent', + 'children' => 'getChildren' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('parent', $data ?? [], null); + $this->setIfExists('children', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор региона. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название региона. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\RegionType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\RegionType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets parent + * + * @return \OpenAPI\Client\Model\RegionDTO|null + */ + public function getParent() + { + return $this->container['parent']; + } + + /** + * Sets parent + * + * @param \OpenAPI\Client\Model\RegionDTO|null $parent parent + * + * @return self + */ + public function setParent($parent) + { + if (is_null($parent)) { + throw new \InvalidArgumentException('non-nullable parent cannot be null'); + } + $this->container['parent'] = $parent; + + return $this; + } + + /** + * Gets children + * + * @return \OpenAPI\Client\Model\RegionDTO[]|null + */ + public function getChildren() + { + return $this->container['children']; + } + + /** + * Sets children + * + * @param \OpenAPI\Client\Model\RegionDTO[]|null $children Дочерние регионы. + * + * @return self + */ + public function setChildren($children) + { + if (is_null($children)) { + array_push($this->openAPINullablesSetToNull, 'children'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('children', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['children'] = $children; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/RegionType.php b/erp24/lib/yandex_market_api/Model/RegionType.php new file mode 100644 index 00000000..0d1b5c90 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/RegionType.php @@ -0,0 +1,90 @@ + + */ +class RegionalModelInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RegionalModelInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'currency' => '\OpenAPI\Client\Model\CurrencyType', + 'region_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'currency' => null, + 'region_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'currency' => false, + 'region_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'currency' => 'currency', + 'region_id' => 'regionId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'currency' => 'setCurrency', + 'region_id' => 'setRegionId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'currency' => 'getCurrency', + 'region_id' => 'getRegionId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('region_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets currency + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets region_id + * + * @return int|null + */ + public function getRegionId() + { + return $this->container['region_id']; + } + + /** + * Sets region_id + * + * @param int|null $region_id Идентификатор региона, для которого выводится информация о предложениях модели (доставляемых в этот регион). Информацию о регионе по идентификатору можно получить с помощью запроса [GET regions/{regionId}](../../reference/regions/searchRegionsById.md). + * + * @return self + */ + public function setRegionId($region_id) + { + if (is_null($region_id)) { + throw new \InvalidArgumentException('non-nullable region_id cannot be null'); + } + $this->container['region_id'] = $region_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/RejectedPromoOfferDeleteDTO.php b/erp24/lib/yandex_market_api/Model/RejectedPromoOfferDeleteDTO.php new file mode 100644 index 00000000..cc7edcfc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/RejectedPromoOfferDeleteDTO.php @@ -0,0 +1,472 @@ + + */ +class RejectedPromoOfferDeleteDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RejectedPromoOfferDeleteDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'reason' => '\OpenAPI\Client\Model\RejectedPromoOfferDeleteReasonType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'reason' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'reason' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'reason' => 'reason' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'reason' => 'setReason' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'reason' => 'getReason' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('reason', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['reason'] === null) { + $invalidProperties[] = "'reason' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling RejectedPromoOfferDeleteDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling RejectedPromoOfferDeleteDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling RejectedPromoOfferDeleteDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets reason + * + * @return \OpenAPI\Client\Model\RejectedPromoOfferDeleteReasonType + */ + public function getReason() + { + return $this->container['reason']; + } + + /** + * Sets reason + * + * @param \OpenAPI\Client\Model\RejectedPromoOfferDeleteReasonType $reason reason + * + * @return self + */ + public function setReason($reason) + { + if (is_null($reason)) { + throw new \InvalidArgumentException('non-nullable reason cannot be null'); + } + $this->container['reason'] = $reason; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/RejectedPromoOfferDeleteReasonType.php b/erp24/lib/yandex_market_api/Model/RejectedPromoOfferDeleteReasonType.php new file mode 100644 index 00000000..cd9bc7b2 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/RejectedPromoOfferDeleteReasonType.php @@ -0,0 +1,60 @@ + + */ +class RejectedPromoOfferUpdateDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'RejectedPromoOfferUpdateDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'reason' => '\OpenAPI\Client\Model\RejectedPromoOfferUpdateReasonType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'reason' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'reason' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'reason' => 'reason' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'reason' => 'setReason' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'reason' => 'getReason' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('reason', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['reason'] === null) { + $invalidProperties[] = "'reason' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling RejectedPromoOfferUpdateDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling RejectedPromoOfferUpdateDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling RejectedPromoOfferUpdateDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets reason + * + * @return \OpenAPI\Client\Model\RejectedPromoOfferUpdateReasonType + */ + public function getReason() + { + return $this->container['reason']; + } + + /** + * Sets reason + * + * @param \OpenAPI\Client\Model\RejectedPromoOfferUpdateReasonType $reason reason + * + * @return self + */ + public function setReason($reason) + { + if (is_null($reason)) { + throw new \InvalidArgumentException('non-nullable reason cannot be null'); + } + $this->container['reason'] = $reason; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/RejectedPromoOfferUpdateReasonType.php b/erp24/lib/yandex_market_api/Model/RejectedPromoOfferUpdateReasonType.php new file mode 100644 index 00000000..422de895 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/RejectedPromoOfferUpdateReasonType.php @@ -0,0 +1,87 @@ + + */ +class ReportInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ReportInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ReportStatusType', + 'sub_status' => '\OpenAPI\Client\Model\ReportSubStatusType', + 'generation_requested_at' => '\DateTime', + 'generation_finished_at' => '\DateTime', + 'file' => 'string', + 'estimated_generation_time' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'sub_status' => null, + 'generation_requested_at' => 'date-time', + 'generation_finished_at' => 'date-time', + 'file' => null, + 'estimated_generation_time' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'sub_status' => false, + 'generation_requested_at' => false, + 'generation_finished_at' => false, + 'file' => false, + 'estimated_generation_time' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'sub_status' => 'subStatus', + 'generation_requested_at' => 'generationRequestedAt', + 'generation_finished_at' => 'generationFinishedAt', + 'file' => 'file', + 'estimated_generation_time' => 'estimatedGenerationTime' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'sub_status' => 'setSubStatus', + 'generation_requested_at' => 'setGenerationRequestedAt', + 'generation_finished_at' => 'setGenerationFinishedAt', + 'file' => 'setFile', + 'estimated_generation_time' => 'setEstimatedGenerationTime' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'sub_status' => 'getSubStatus', + 'generation_requested_at' => 'getGenerationRequestedAt', + 'generation_finished_at' => 'getGenerationFinishedAt', + 'file' => 'getFile', + 'estimated_generation_time' => 'getEstimatedGenerationTime' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('sub_status', $data ?? [], null); + $this->setIfExists('generation_requested_at', $data ?? [], null); + $this->setIfExists('generation_finished_at', $data ?? [], null); + $this->setIfExists('file', $data ?? [], null); + $this->setIfExists('estimated_generation_time', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['status'] === null) { + $invalidProperties[] = "'status' can't be null"; + } + if ($this->container['generation_requested_at'] === null) { + $invalidProperties[] = "'generation_requested_at' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ReportStatusType + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ReportStatusType $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets sub_status + * + * @return \OpenAPI\Client\Model\ReportSubStatusType|null + */ + public function getSubStatus() + { + return $this->container['sub_status']; + } + + /** + * Sets sub_status + * + * @param \OpenAPI\Client\Model\ReportSubStatusType|null $sub_status sub_status + * + * @return self + */ + public function setSubStatus($sub_status) + { + if (is_null($sub_status)) { + throw new \InvalidArgumentException('non-nullable sub_status cannot be null'); + } + $this->container['sub_status'] = $sub_status; + + return $this; + } + + /** + * Gets generation_requested_at + * + * @return \DateTime + */ + public function getGenerationRequestedAt() + { + return $this->container['generation_requested_at']; + } + + /** + * Sets generation_requested_at + * + * @param \DateTime $generation_requested_at Дата и время запроса на генерацию. + * + * @return self + */ + public function setGenerationRequestedAt($generation_requested_at) + { + if (is_null($generation_requested_at)) { + throw new \InvalidArgumentException('non-nullable generation_requested_at cannot be null'); + } + $this->container['generation_requested_at'] = $generation_requested_at; + + return $this; + } + + /** + * Gets generation_finished_at + * + * @return \DateTime|null + */ + public function getGenerationFinishedAt() + { + return $this->container['generation_finished_at']; + } + + /** + * Sets generation_finished_at + * + * @param \DateTime|null $generation_finished_at Дата и время завершения генерации. + * + * @return self + */ + public function setGenerationFinishedAt($generation_finished_at) + { + if (is_null($generation_finished_at)) { + throw new \InvalidArgumentException('non-nullable generation_finished_at cannot be null'); + } + $this->container['generation_finished_at'] = $generation_finished_at; + + return $this; + } + + /** + * Gets file + * + * @return string|null + */ + public function getFile() + { + return $this->container['file']; + } + + /** + * Sets file + * + * @param string|null $file Ссылка на готовый отчет. + * + * @return self + */ + public function setFile($file) + { + if (is_null($file)) { + throw new \InvalidArgumentException('non-nullable file cannot be null'); + } + $this->container['file'] = $file; + + return $this; + } + + /** + * Gets estimated_generation_time + * + * @return int|null + */ + public function getEstimatedGenerationTime() + { + return $this->container['estimated_generation_time']; + } + + /** + * Sets estimated_generation_time + * + * @param int|null $estimated_generation_time Ожидаемая продолжительность генерации в миллисекундах. + * + * @return self + */ + public function setEstimatedGenerationTime($estimated_generation_time) + { + if (is_null($estimated_generation_time)) { + throw new \InvalidArgumentException('non-nullable estimated_generation_time cannot be null'); + } + $this->container['estimated_generation_time'] = $estimated_generation_time; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ReportStatusType.php b/erp24/lib/yandex_market_api/Model/ReportStatusType.php new file mode 100644 index 00000000..f97aab60 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ReportStatusType.php @@ -0,0 +1,69 @@ + + */ +class ReturnDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ReturnDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'order_id' => 'int', + 'creation_date' => '\DateTime', + 'update_date' => '\DateTime', + 'refund_status' => '\OpenAPI\Client\Model\RefundStatusType', + 'logistic_pickup_point' => '\OpenAPI\Client\Model\LogisticPickupPointDTO', + 'shipment_recipient_type' => '\OpenAPI\Client\Model\RecipientType', + 'shipment_status' => '\OpenAPI\Client\Model\ReturnShipmentStatusType', + 'refund_amount' => 'int', + 'items' => '\OpenAPI\Client\Model\ReturnItemDTO[]', + 'return_type' => '\OpenAPI\Client\Model\ReturnType', + 'fast_return' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'order_id' => 'int64', + 'creation_date' => 'date-time', + 'update_date' => 'date-time', + 'refund_status' => null, + 'logistic_pickup_point' => null, + 'shipment_recipient_type' => null, + 'shipment_status' => null, + 'refund_amount' => 'int64', + 'items' => null, + 'return_type' => null, + 'fast_return' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'order_id' => false, + 'creation_date' => false, + 'update_date' => false, + 'refund_status' => false, + 'logistic_pickup_point' => false, + 'shipment_recipient_type' => false, + 'shipment_status' => false, + 'refund_amount' => false, + 'items' => false, + 'return_type' => false, + 'fast_return' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'order_id' => 'orderId', + 'creation_date' => 'creationDate', + 'update_date' => 'updateDate', + 'refund_status' => 'refundStatus', + 'logistic_pickup_point' => 'logisticPickupPoint', + 'shipment_recipient_type' => 'shipmentRecipientType', + 'shipment_status' => 'shipmentStatus', + 'refund_amount' => 'refundAmount', + 'items' => 'items', + 'return_type' => 'returnType', + 'fast_return' => 'fastReturn' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'order_id' => 'setOrderId', + 'creation_date' => 'setCreationDate', + 'update_date' => 'setUpdateDate', + 'refund_status' => 'setRefundStatus', + 'logistic_pickup_point' => 'setLogisticPickupPoint', + 'shipment_recipient_type' => 'setShipmentRecipientType', + 'shipment_status' => 'setShipmentStatus', + 'refund_amount' => 'setRefundAmount', + 'items' => 'setItems', + 'return_type' => 'setReturnType', + 'fast_return' => 'setFastReturn' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'order_id' => 'getOrderId', + 'creation_date' => 'getCreationDate', + 'update_date' => 'getUpdateDate', + 'refund_status' => 'getRefundStatus', + 'logistic_pickup_point' => 'getLogisticPickupPoint', + 'shipment_recipient_type' => 'getShipmentRecipientType', + 'shipment_status' => 'getShipmentStatus', + 'refund_amount' => 'getRefundAmount', + 'items' => 'getItems', + 'return_type' => 'getReturnType', + 'fast_return' => 'getFastReturn' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('order_id', $data ?? [], null); + $this->setIfExists('creation_date', $data ?? [], null); + $this->setIfExists('update_date', $data ?? [], null); + $this->setIfExists('refund_status', $data ?? [], null); + $this->setIfExists('logistic_pickup_point', $data ?? [], null); + $this->setIfExists('shipment_recipient_type', $data ?? [], null); + $this->setIfExists('shipment_status', $data ?? [], null); + $this->setIfExists('refund_amount', $data ?? [], null); + $this->setIfExists('items', $data ?? [], null); + $this->setIfExists('return_type', $data ?? [], null); + $this->setIfExists('fast_return', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['order_id'] === null) { + $invalidProperties[] = "'order_id' can't be null"; + } + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + if ($this->container['return_type'] === null) { + $invalidProperties[] = "'return_type' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор возврата. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets order_id + * + * @return int + */ + public function getOrderId() + { + return $this->container['order_id']; + } + + /** + * Sets order_id + * + * @param int $order_id Номер заказа. + * + * @return self + */ + public function setOrderId($order_id) + { + if (is_null($order_id)) { + throw new \InvalidArgumentException('non-nullable order_id cannot be null'); + } + $this->container['order_id'] = $order_id; + + return $this; + } + + /** + * Gets creation_date + * + * @return \DateTime|null + */ + public function getCreationDate() + { + return $this->container['creation_date']; + } + + /** + * Sets creation_date + * + * @param \DateTime|null $creation_date Дата создания возврата клиентом. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setCreationDate($creation_date) + { + if (is_null($creation_date)) { + throw new \InvalidArgumentException('non-nullable creation_date cannot be null'); + } + $this->container['creation_date'] = $creation_date; + + return $this; + } + + /** + * Gets update_date + * + * @return \DateTime|null + */ + public function getUpdateDate() + { + return $this->container['update_date']; + } + + /** + * Sets update_date + * + * @param \DateTime|null $update_date Дата обновления возврата. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setUpdateDate($update_date) + { + if (is_null($update_date)) { + throw new \InvalidArgumentException('non-nullable update_date cannot be null'); + } + $this->container['update_date'] = $update_date; + + return $this; + } + + /** + * Gets refund_status + * + * @return \OpenAPI\Client\Model\RefundStatusType|null + */ + public function getRefundStatus() + { + return $this->container['refund_status']; + } + + /** + * Sets refund_status + * + * @param \OpenAPI\Client\Model\RefundStatusType|null $refund_status refund_status + * + * @return self + */ + public function setRefundStatus($refund_status) + { + if (is_null($refund_status)) { + throw new \InvalidArgumentException('non-nullable refund_status cannot be null'); + } + $this->container['refund_status'] = $refund_status; + + return $this; + } + + /** + * Gets logistic_pickup_point + * + * @return \OpenAPI\Client\Model\LogisticPickupPointDTO|null + */ + public function getLogisticPickupPoint() + { + return $this->container['logistic_pickup_point']; + } + + /** + * Sets logistic_pickup_point + * + * @param \OpenAPI\Client\Model\LogisticPickupPointDTO|null $logistic_pickup_point logistic_pickup_point + * + * @return self + */ + public function setLogisticPickupPoint($logistic_pickup_point) + { + if (is_null($logistic_pickup_point)) { + throw new \InvalidArgumentException('non-nullable logistic_pickup_point cannot be null'); + } + $this->container['logistic_pickup_point'] = $logistic_pickup_point; + + return $this; + } + + /** + * Gets shipment_recipient_type + * + * @return \OpenAPI\Client\Model\RecipientType|null + */ + public function getShipmentRecipientType() + { + return $this->container['shipment_recipient_type']; + } + + /** + * Sets shipment_recipient_type + * + * @param \OpenAPI\Client\Model\RecipientType|null $shipment_recipient_type shipment_recipient_type + * + * @return self + */ + public function setShipmentRecipientType($shipment_recipient_type) + { + if (is_null($shipment_recipient_type)) { + throw new \InvalidArgumentException('non-nullable shipment_recipient_type cannot be null'); + } + $this->container['shipment_recipient_type'] = $shipment_recipient_type; + + return $this; + } + + /** + * Gets shipment_status + * + * @return \OpenAPI\Client\Model\ReturnShipmentStatusType|null + */ + public function getShipmentStatus() + { + return $this->container['shipment_status']; + } + + /** + * Sets shipment_status + * + * @param \OpenAPI\Client\Model\ReturnShipmentStatusType|null $shipment_status shipment_status + * + * @return self + */ + public function setShipmentStatus($shipment_status) + { + if (is_null($shipment_status)) { + throw new \InvalidArgumentException('non-nullable shipment_status cannot be null'); + } + $this->container['shipment_status'] = $shipment_status; + + return $this; + } + + /** + * Gets refund_amount + * + * @return int|null + */ + public function getRefundAmount() + { + return $this->container['refund_amount']; + } + + /** + * Sets refund_amount + * + * @param int|null $refund_amount Сумма возврата. + * + * @return self + */ + public function setRefundAmount($refund_amount) + { + if (is_null($refund_amount)) { + throw new \InvalidArgumentException('non-nullable refund_amount cannot be null'); + } + $this->container['refund_amount'] = $refund_amount; + + return $this; + } + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\ReturnItemDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\ReturnItemDTO[] $items Список товаров в возврате. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets return_type + * + * @return \OpenAPI\Client\Model\ReturnType + */ + public function getReturnType() + { + return $this->container['return_type']; + } + + /** + * Sets return_type + * + * @param \OpenAPI\Client\Model\ReturnType $return_type return_type + * + * @return self + */ + public function setReturnType($return_type) + { + if (is_null($return_type)) { + throw new \InvalidArgumentException('non-nullable return_type cannot be null'); + } + $this->container['return_type'] = $return_type; + + return $this; + } + + /** + * Gets fast_return + * + * @return bool|null + */ + public function getFastReturn() + { + return $this->container['fast_return']; + } + + /** + * Sets fast_return + * + * @param bool|null $fast_return Используется ли опция **Быстрый возврат денег за дешевый брак**. + * + * @return self + */ + public function setFastReturn($fast_return) + { + if (is_null($fast_return)) { + throw new \InvalidArgumentException('non-nullable fast_return cannot be null'); + } + $this->container['fast_return'] = $fast_return; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ReturnDecisionDTO.php b/erp24/lib/yandex_market_api/Model/ReturnDecisionDTO.php new file mode 100644 index 00000000..50bc63af --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ReturnDecisionDTO.php @@ -0,0 +1,689 @@ + + */ +class ReturnDecisionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ReturnDecisionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'return_item_id' => 'int', + 'count' => 'int', + 'comment' => 'string', + 'reason_type' => '\OpenAPI\Client\Model\ReturnDecisionReasonType', + 'subreason_type' => '\OpenAPI\Client\Model\ReturnDecisionSubreasonType', + 'decision_type' => '\OpenAPI\Client\Model\ReturnDecisionType', + 'refund_amount' => 'int', + 'partner_compensation' => 'int', + 'images' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'return_item_id' => 'int64', + 'count' => 'int32', + 'comment' => null, + 'reason_type' => null, + 'subreason_type' => null, + 'decision_type' => null, + 'refund_amount' => 'int64', + 'partner_compensation' => 'int64', + 'images' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'return_item_id' => false, + 'count' => false, + 'comment' => false, + 'reason_type' => false, + 'subreason_type' => false, + 'decision_type' => false, + 'refund_amount' => false, + 'partner_compensation' => false, + 'images' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'return_item_id' => 'returnItemId', + 'count' => 'count', + 'comment' => 'comment', + 'reason_type' => 'reasonType', + 'subreason_type' => 'subreasonType', + 'decision_type' => 'decisionType', + 'refund_amount' => 'refundAmount', + 'partner_compensation' => 'partnerCompensation', + 'images' => 'images' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'return_item_id' => 'setReturnItemId', + 'count' => 'setCount', + 'comment' => 'setComment', + 'reason_type' => 'setReasonType', + 'subreason_type' => 'setSubreasonType', + 'decision_type' => 'setDecisionType', + 'refund_amount' => 'setRefundAmount', + 'partner_compensation' => 'setPartnerCompensation', + 'images' => 'setImages' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'return_item_id' => 'getReturnItemId', + 'count' => 'getCount', + 'comment' => 'getComment', + 'reason_type' => 'getReasonType', + 'subreason_type' => 'getSubreasonType', + 'decision_type' => 'getDecisionType', + 'refund_amount' => 'getRefundAmount', + 'partner_compensation' => 'getPartnerCompensation', + 'images' => 'getImages' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('return_item_id', $data ?? [], null); + $this->setIfExists('count', $data ?? [], null); + $this->setIfExists('comment', $data ?? [], null); + $this->setIfExists('reason_type', $data ?? [], null); + $this->setIfExists('subreason_type', $data ?? [], null); + $this->setIfExists('decision_type', $data ?? [], null); + $this->setIfExists('refund_amount', $data ?? [], null); + $this->setIfExists('partner_compensation', $data ?? [], null); + $this->setIfExists('images', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets return_item_id + * + * @return int|null + */ + public function getReturnItemId() + { + return $this->container['return_item_id']; + } + + /** + * Sets return_item_id + * + * @param int|null $return_item_id Идентификатор товара в возврате. + * + * @return self + */ + public function setReturnItemId($return_item_id) + { + if (is_null($return_item_id)) { + throw new \InvalidArgumentException('non-nullable return_item_id cannot be null'); + } + $this->container['return_item_id'] = $return_item_id; + + return $this; + } + + /** + * Gets count + * + * @return int|null + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param int|null $count Количество единиц товара. + * + * @return self + */ + public function setCount($count) + { + if (is_null($count)) { + throw new \InvalidArgumentException('non-nullable count cannot be null'); + } + $this->container['count'] = $count; + + return $this; + } + + /** + * Gets comment + * + * @return string|null + */ + public function getComment() + { + return $this->container['comment']; + } + + /** + * Sets comment + * + * @param string|null $comment Комментарий. + * + * @return self + */ + public function setComment($comment) + { + if (is_null($comment)) { + throw new \InvalidArgumentException('non-nullable comment cannot be null'); + } + $this->container['comment'] = $comment; + + return $this; + } + + /** + * Gets reason_type + * + * @return \OpenAPI\Client\Model\ReturnDecisionReasonType|null + */ + public function getReasonType() + { + return $this->container['reason_type']; + } + + /** + * Sets reason_type + * + * @param \OpenAPI\Client\Model\ReturnDecisionReasonType|null $reason_type reason_type + * + * @return self + */ + public function setReasonType($reason_type) + { + if (is_null($reason_type)) { + throw new \InvalidArgumentException('non-nullable reason_type cannot be null'); + } + $this->container['reason_type'] = $reason_type; + + return $this; + } + + /** + * Gets subreason_type + * + * @return \OpenAPI\Client\Model\ReturnDecisionSubreasonType|null + */ + public function getSubreasonType() + { + return $this->container['subreason_type']; + } + + /** + * Sets subreason_type + * + * @param \OpenAPI\Client\Model\ReturnDecisionSubreasonType|null $subreason_type subreason_type + * + * @return self + */ + public function setSubreasonType($subreason_type) + { + if (is_null($subreason_type)) { + throw new \InvalidArgumentException('non-nullable subreason_type cannot be null'); + } + $this->container['subreason_type'] = $subreason_type; + + return $this; + } + + /** + * Gets decision_type + * + * @return \OpenAPI\Client\Model\ReturnDecisionType|null + */ + public function getDecisionType() + { + return $this->container['decision_type']; + } + + /** + * Sets decision_type + * + * @param \OpenAPI\Client\Model\ReturnDecisionType|null $decision_type decision_type + * + * @return self + */ + public function setDecisionType($decision_type) + { + if (is_null($decision_type)) { + throw new \InvalidArgumentException('non-nullable decision_type cannot be null'); + } + $this->container['decision_type'] = $decision_type; + + return $this; + } + + /** + * Gets refund_amount + * + * @return int|null + */ + public function getRefundAmount() + { + return $this->container['refund_amount']; + } + + /** + * Sets refund_amount + * + * @param int|null $refund_amount Сумма возврата. + * + * @return self + */ + public function setRefundAmount($refund_amount) + { + if (is_null($refund_amount)) { + throw new \InvalidArgumentException('non-nullable refund_amount cannot be null'); + } + $this->container['refund_amount'] = $refund_amount; + + return $this; + } + + /** + * Gets partner_compensation + * + * @return int|null + */ + public function getPartnerCompensation() + { + return $this->container['partner_compensation']; + } + + /** + * Sets partner_compensation + * + * @param int|null $partner_compensation Компенсация за обратную доставку. + * + * @return self + */ + public function setPartnerCompensation($partner_compensation) + { + if (is_null($partner_compensation)) { + throw new \InvalidArgumentException('non-nullable partner_compensation cannot be null'); + } + $this->container['partner_compensation'] = $partner_compensation; + + return $this; + } + + /** + * Gets images + * + * @return string[]|null + */ + public function getImages() + { + return $this->container['images']; + } + + /** + * Sets images + * + * @param string[]|null $images Список хеш-кодов фотографий товара от покупателя. + * + * @return self + */ + public function setImages($images) + { + if (is_null($images)) { + array_push($this->openAPINullablesSetToNull, 'images'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('images', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['images'] = $images; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ReturnDecisionReasonType.php b/erp24/lib/yandex_market_api/Model/ReturnDecisionReasonType.php new file mode 100644 index 00000000..4d7161b0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ReturnDecisionReasonType.php @@ -0,0 +1,78 @@ + + */ +class ReturnInstanceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ReturnInstanceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'stock_type' => '\OpenAPI\Client\Model\ReturnInstanceStockType', + 'status' => '\OpenAPI\Client\Model\ReturnInstanceStatusType', + 'cis' => 'string', + 'imei' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'stock_type' => null, + 'status' => null, + 'cis' => null, + 'imei' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'stock_type' => false, + 'status' => false, + 'cis' => false, + 'imei' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'stock_type' => 'stockType', + 'status' => 'status', + 'cis' => 'cis', + 'imei' => 'imei' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'stock_type' => 'setStockType', + 'status' => 'setStatus', + 'cis' => 'setCis', + 'imei' => 'setImei' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'stock_type' => 'getStockType', + 'status' => 'getStatus', + 'cis' => 'getCis', + 'imei' => 'getImei' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('stock_type', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('cis', $data ?? [], null); + $this->setIfExists('imei', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets stock_type + * + * @return \OpenAPI\Client\Model\ReturnInstanceStockType|null + */ + public function getStockType() + { + return $this->container['stock_type']; + } + + /** + * Sets stock_type + * + * @param \OpenAPI\Client\Model\ReturnInstanceStockType|null $stock_type stock_type + * + * @return self + */ + public function setStockType($stock_type) + { + if (is_null($stock_type)) { + throw new \InvalidArgumentException('non-nullable stock_type cannot be null'); + } + $this->container['stock_type'] = $stock_type; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ReturnInstanceStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ReturnInstanceStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets cis + * + * @return string|null + */ + public function getCis() + { + return $this->container['cis']; + } + + /** + * Sets cis + * + * @param string|null $cis Код идентификации единицы товара [в системе «Честный ЗНАК»](https://честныйзнак.рф/). + * + * @return self + */ + public function setCis($cis) + { + if (is_null($cis)) { + throw new \InvalidArgumentException('non-nullable cis cannot be null'); + } + $this->container['cis'] = $cis; + + return $this; + } + + /** + * Gets imei + * + * @return string|null + */ + public function getImei() + { + return $this->container['imei']; + } + + /** + * Sets imei + * + * @param string|null $imei Международный идентификатор мобильного оборудования. + * + * @return self + */ + public function setImei($imei) + { + if (is_null($imei)) { + throw new \InvalidArgumentException('non-nullable imei cannot be null'); + } + $this->container['imei'] = $imei; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ReturnInstanceStatusType.php b/erp24/lib/yandex_market_api/Model/ReturnInstanceStatusType.php new file mode 100644 index 00000000..f4d83ebf --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ReturnInstanceStatusType.php @@ -0,0 +1,93 @@ + + */ +class ReturnItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ReturnItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'market_sku' => 'int', + 'shop_sku' => 'string', + 'count' => 'int', + 'decisions' => '\OpenAPI\Client\Model\ReturnDecisionDTO[]', + 'instances' => '\OpenAPI\Client\Model\ReturnInstanceDTO[]', + 'tracks' => '\OpenAPI\Client\Model\TrackDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'market_sku' => 'int64', + 'shop_sku' => null, + 'count' => 'int64', + 'decisions' => null, + 'instances' => null, + 'tracks' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'market_sku' => false, + 'shop_sku' => false, + 'count' => false, + 'decisions' => true, + 'instances' => true, + 'tracks' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'market_sku' => 'marketSku', + 'shop_sku' => 'shopSku', + 'count' => 'count', + 'decisions' => 'decisions', + 'instances' => 'instances', + 'tracks' => 'tracks' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'market_sku' => 'setMarketSku', + 'shop_sku' => 'setShopSku', + 'count' => 'setCount', + 'decisions' => 'setDecisions', + 'instances' => 'setInstances', + 'tracks' => 'setTracks' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'market_sku' => 'getMarketSku', + 'shop_sku' => 'getShopSku', + 'count' => 'getCount', + 'decisions' => 'getDecisions', + 'instances' => 'getInstances', + 'tracks' => 'getTracks' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('market_sku', $data ?? [], null); + $this->setIfExists('shop_sku', $data ?? [], null); + $this->setIfExists('count', $data ?? [], null); + $this->setIfExists('decisions', $data ?? [], null); + $this->setIfExists('instances', $data ?? [], null); + $this->setIfExists('tracks', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + if ($this->container['shop_sku'] === null) { + $invalidProperties[] = "'shop_sku' can't be null"; + } + if ((mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['count'] === null) { + $invalidProperties[] = "'count' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling ReturnItemDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + + /** + * Gets shop_sku + * + * @return string + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling ReturnItemDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling ReturnItemDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling ReturnItemDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + + /** + * Gets count + * + * @return int + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param int $count Количество единиц товара. + * + * @return self + */ + public function setCount($count) + { + if (is_null($count)) { + throw new \InvalidArgumentException('non-nullable count cannot be null'); + } + $this->container['count'] = $count; + + return $this; + } + + /** + * Gets decisions + * + * @return \OpenAPI\Client\Model\ReturnDecisionDTO[]|null + */ + public function getDecisions() + { + return $this->container['decisions']; + } + + /** + * Sets decisions + * + * @param \OpenAPI\Client\Model\ReturnDecisionDTO[]|null $decisions Список решений по возврату. + * + * @return self + */ + public function setDecisions($decisions) + { + if (is_null($decisions)) { + array_push($this->openAPINullablesSetToNull, 'decisions'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('decisions', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['decisions'] = $decisions; + + return $this; + } + + /** + * Gets instances + * + * @return \OpenAPI\Client\Model\ReturnInstanceDTO[]|null + */ + public function getInstances() + { + return $this->container['instances']; + } + + /** + * Sets instances + * + * @param \OpenAPI\Client\Model\ReturnInstanceDTO[]|null $instances Список логистических позиций возврата. + * + * @return self + */ + public function setInstances($instances) + { + if (is_null($instances)) { + array_push($this->openAPINullablesSetToNull, 'instances'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('instances', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['instances'] = $instances; + + return $this; + } + + /** + * Gets tracks + * + * @return \OpenAPI\Client\Model\TrackDTO[]|null + */ + public function getTracks() + { + return $this->container['tracks']; + } + + /** + * Sets tracks + * + * @param \OpenAPI\Client\Model\TrackDTO[]|null $tracks Список трек-кодов для почтовых отправлений. + * + * @return self + */ + public function setTracks($tracks) + { + if (is_null($tracks)) { + array_push($this->openAPINullablesSetToNull, 'tracks'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tracks', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tracks'] = $tracks; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ReturnRequestDecisionType.php b/erp24/lib/yandex_market_api/Model/ReturnRequestDecisionType.php new file mode 100644 index 00000000..c40fce52 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ReturnRequestDecisionType.php @@ -0,0 +1,78 @@ + + */ +class ScrollingPagerDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ScrollingPagerDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'next_page_token' => 'string', + 'prev_page_token' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'next_page_token' => null, + 'prev_page_token' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'next_page_token' => false, + 'prev_page_token' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'next_page_token' => 'nextPageToken', + 'prev_page_token' => 'prevPageToken' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'next_page_token' => 'setNextPageToken', + 'prev_page_token' => 'setPrevPageToken' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'next_page_token' => 'getNextPageToken', + 'prev_page_token' => 'getPrevPageToken' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('next_page_token', $data ?? [], null); + $this->setIfExists('prev_page_token', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets next_page_token + * + * @return string|null + */ + public function getNextPageToken() + { + return $this->container['next_page_token']; + } + + /** + * Sets next_page_token + * + * @param string|null $next_page_token Идентификатор следующей страницы результатов. + * + * @return self + */ + public function setNextPageToken($next_page_token) + { + if (is_null($next_page_token)) { + throw new \InvalidArgumentException('non-nullable next_page_token cannot be null'); + } + $this->container['next_page_token'] = $next_page_token; + + return $this; + } + + /** + * Gets prev_page_token + * + * @return string|null + */ + public function getPrevPageToken() + { + return $this->container['prev_page_token']; + } + + /** + * Sets prev_page_token + * + * @param string|null $prev_page_token Идентификатор предыдущей страницы результатов. + * + * @return self + */ + public function setPrevPageToken($prev_page_token) + { + if (is_null($prev_page_token)) { + throw new \InvalidArgumentException('non-nullable prev_page_token cannot be null'); + } + $this->container['prev_page_token'] = $prev_page_token; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SearchModelsResponse.php b/erp24/lib/yandex_market_api/Model/SearchModelsResponse.php new file mode 100644 index 00000000..c0bfe4b4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SearchModelsResponse.php @@ -0,0 +1,514 @@ + + */ +class SearchModelsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SearchModelsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'models' => '\OpenAPI\Client\Model\ModelDTO[]', + 'currency' => '\OpenAPI\Client\Model\CurrencyType', + 'region_id' => 'int', + 'pager' => '\OpenAPI\Client\Model\FlippingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'models' => null, + 'currency' => null, + 'region_id' => 'int64', + 'pager' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'models' => false, + 'currency' => false, + 'region_id' => false, + 'pager' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'models' => 'models', + 'currency' => 'currency', + 'region_id' => 'regionId', + 'pager' => 'pager' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'models' => 'setModels', + 'currency' => 'setCurrency', + 'region_id' => 'setRegionId', + 'pager' => 'setPager' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'models' => 'getModels', + 'currency' => 'getCurrency', + 'region_id' => 'getRegionId', + 'pager' => 'getPager' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('models', $data ?? [], null); + $this->setIfExists('currency', $data ?? [], null); + $this->setIfExists('region_id', $data ?? [], null); + $this->setIfExists('pager', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['models'] === null) { + $invalidProperties[] = "'models' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets models + * + * @return \OpenAPI\Client\Model\ModelDTO[] + */ + public function getModels() + { + return $this->container['models']; + } + + /** + * Sets models + * + * @param \OpenAPI\Client\Model\ModelDTO[] $models Список моделей товаров. + * + * @return self + */ + public function setModels($models) + { + if (is_null($models)) { + throw new \InvalidArgumentException('non-nullable models cannot be null'); + } + $this->container['models'] = $models; + + return $this; + } + + /** + * Gets currency + * + * @return \OpenAPI\Client\Model\CurrencyType|null + */ + public function getCurrency() + { + return $this->container['currency']; + } + + /** + * Sets currency + * + * @param \OpenAPI\Client\Model\CurrencyType|null $currency currency + * + * @return self + */ + public function setCurrency($currency) + { + if (is_null($currency)) { + throw new \InvalidArgumentException('non-nullable currency cannot be null'); + } + $this->container['currency'] = $currency; + + return $this; + } + + /** + * Gets region_id + * + * @return int|null + */ + public function getRegionId() + { + return $this->container['region_id']; + } + + /** + * Sets region_id + * + * @param int|null $region_id Идентификатор региона, для которого выводится информация о предложениях модели (доставляемых в этот регион). Информацию о регионе по идентификатору можно получить с помощью запроса [GET regions/{regionId}](../../reference/regions/searchRegionsById.md). + * + * @return self + */ + public function setRegionId($region_id) + { + if (is_null($region_id)) { + throw new \InvalidArgumentException('non-nullable region_id cannot be null'); + } + $this->container['region_id'] = $region_id; + + return $this; + } + + /** + * Gets pager + * + * @return \OpenAPI\Client\Model\FlippingPagerDTO|null + */ + public function getPager() + { + return $this->container['pager']; + } + + /** + * Sets pager + * + * @param \OpenAPI\Client\Model\FlippingPagerDTO|null $pager pager + * + * @return self + */ + public function setPager($pager) + { + if (is_null($pager)) { + throw new \InvalidArgumentException('non-nullable pager cannot be null'); + } + $this->container['pager'] = $pager; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SearchShipmentsRequest.php b/erp24/lib/yandex_market_api/Model/SearchShipmentsRequest.php new file mode 100644 index 00000000..aadfdecd --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SearchShipmentsRequest.php @@ -0,0 +1,584 @@ + + */ +class SearchShipmentsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SearchShipmentsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'date_from' => '\DateTime', + 'date_to' => '\DateTime', + 'statuses' => '\OpenAPI\Client\Model\ShipmentStatusType[]', + 'order_ids' => 'int[]', + 'cancelled_orders' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'date_from' => 'date', + 'date_to' => 'date', + 'statuses' => null, + 'order_ids' => 'int64', + 'cancelled_orders' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'date_from' => false, + 'date_to' => false, + 'statuses' => true, + 'order_ids' => true, + 'cancelled_orders' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'date_from' => 'dateFrom', + 'date_to' => 'dateTo', + 'statuses' => 'statuses', + 'order_ids' => 'orderIds', + 'cancelled_orders' => 'cancelledOrders' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'date_from' => 'setDateFrom', + 'date_to' => 'setDateTo', + 'statuses' => 'setStatuses', + 'order_ids' => 'setOrderIds', + 'cancelled_orders' => 'setCancelledOrders' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'date_from' => 'getDateFrom', + 'date_to' => 'getDateTo', + 'statuses' => 'getStatuses', + 'order_ids' => 'getOrderIds', + 'cancelled_orders' => 'getCancelledOrders' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('date_from', $data ?? [], null); + $this->setIfExists('date_to', $data ?? [], null); + $this->setIfExists('statuses', $data ?? [], null); + $this->setIfExists('order_ids', $data ?? [], null); + $this->setIfExists('cancelled_orders', $data ?? [], true); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['date_from'] === null) { + $invalidProperties[] = "'date_from' can't be null"; + } + if ($this->container['date_to'] === null) { + $invalidProperties[] = "'date_to' can't be null"; + } + if (!is_null($this->container['statuses']) && (count($this->container['statuses']) < 1)) { + $invalidProperties[] = "invalid value for 'statuses', number of items must be greater than or equal to 1."; + } + + if (!is_null($this->container['order_ids']) && (count($this->container['order_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'order_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets date_from + * + * @return \DateTime + */ + public function getDateFrom() + { + return $this->container['date_from']; + } + + /** + * Sets date_from + * + * @param \DateTime $date_from Начальная дата для фильтрации по дате отгрузки (включительно). Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setDateFrom($date_from) + { + if (is_null($date_from)) { + throw new \InvalidArgumentException('non-nullable date_from cannot be null'); + } + $this->container['date_from'] = $date_from; + + return $this; + } + + /** + * Gets date_to + * + * @return \DateTime + */ + public function getDateTo() + { + return $this->container['date_to']; + } + + /** + * Sets date_to + * + * @param \DateTime $date_to Конечная дата для фильтрации по дате отгрузки (включительно). Формат даты: `ДД-ММ-ГГГГ`. + * + * @return self + */ + public function setDateTo($date_to) + { + if (is_null($date_to)) { + throw new \InvalidArgumentException('non-nullable date_to cannot be null'); + } + $this->container['date_to'] = $date_to; + + return $this; + } + + /** + * Gets statuses + * + * @return \OpenAPI\Client\Model\ShipmentStatusType[]|null + */ + public function getStatuses() + { + return $this->container['statuses']; + } + + /** + * Sets statuses + * + * @param \OpenAPI\Client\Model\ShipmentStatusType[]|null $statuses Список статусов отгрузок. + * + * @return self + */ + public function setStatuses($statuses) + { + if (is_null($statuses)) { + array_push($this->openAPINullablesSetToNull, 'statuses'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('statuses', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($statuses) && (count($statuses) < 1)) { + throw new \InvalidArgumentException('invalid length for $statuses when calling SearchShipmentsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['statuses'] = $statuses; + + return $this; + } + + /** + * Gets order_ids + * + * @return int[]|null + */ + public function getOrderIds() + { + return $this->container['order_ids']; + } + + /** + * Sets order_ids + * + * @param int[]|null $order_ids Список идентификаторов заказов из отгрузок. + * + * @return self + */ + public function setOrderIds($order_ids) + { + if (is_null($order_ids)) { + array_push($this->openAPINullablesSetToNull, 'order_ids'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('order_ids', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + + if (!is_null($order_ids) && (count($order_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $order_ids when calling SearchShipmentsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['order_ids'] = $order_ids; + + return $this; + } + + /** + * Gets cancelled_orders + * + * @return bool|null + */ + public function getCancelledOrders() + { + return $this->container['cancelled_orders']; + } + + /** + * Sets cancelled_orders + * + * @param bool|null $cancelled_orders Возвращать ли отмененные заказы. Значение по умолчанию — `true`. Если возвращать отмененные заказы не нужно, передайте значение `false`. + * + * @return self + */ + public function setCancelledOrders($cancelled_orders) + { + if (is_null($cancelled_orders)) { + throw new \InvalidArgumentException('non-nullable cancelled_orders cannot be null'); + } + $this->container['cancelled_orders'] = $cancelled_orders; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SearchShipmentsResponse.php b/erp24/lib/yandex_market_api/Model/SearchShipmentsResponse.php new file mode 100644 index 00000000..532e1695 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SearchShipmentsResponse.php @@ -0,0 +1,444 @@ + + */ +class SearchShipmentsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SearchShipmentsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\SearchShipmentsResponseDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\SearchShipmentsResponseDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\SearchShipmentsResponseDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SearchShipmentsResponseDTO.php b/erp24/lib/yandex_market_api/Model/SearchShipmentsResponseDTO.php new file mode 100644 index 00000000..e4c45220 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SearchShipmentsResponseDTO.php @@ -0,0 +1,447 @@ + + */ +class SearchShipmentsResponseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SearchShipmentsResponseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'shipments' => '\OpenAPI\Client\Model\ShipmentInfoDTO[]', + 'paging' => '\OpenAPI\Client\Model\ForwardScrollingPagerDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'shipments' => null, + 'paging' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'shipments' => false, + 'paging' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'shipments' => 'shipments', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'shipments' => 'setShipments', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'shipments' => 'getShipments', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('shipments', $data ?? [], null); + $this->setIfExists('paging', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['shipments'] === null) { + $invalidProperties[] = "'shipments' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets shipments + * + * @return \OpenAPI\Client\Model\ShipmentInfoDTO[] + */ + public function getShipments() + { + return $this->container['shipments']; + } + + /** + * Sets shipments + * + * @param \OpenAPI\Client\Model\ShipmentInfoDTO[] $shipments Список с информацией об отгрузках. + * + * @return self + */ + public function setShipments($shipments) + { + if (is_null($shipments)) { + throw new \InvalidArgumentException('non-nullable shipments cannot be null'); + } + $this->container['shipments'] = $shipments; + + return $this; + } + + /** + * Gets paging + * + * @return \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \OpenAPI\Client\Model\ForwardScrollingPagerDTO|null $paging paging + * + * @return self + */ + public function setPaging($paging) + { + if (is_null($paging)) { + throw new \InvalidArgumentException('non-nullable paging cannot be null'); + } + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SellingProgramType.php b/erp24/lib/yandex_market_api/Model/SellingProgramType.php new file mode 100644 index 00000000..d6a22f15 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SellingProgramType.php @@ -0,0 +1,69 @@ + + */ +class SendMessageToChatRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SendMessageToChatRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'message' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'message' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'message' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('message', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['message'] === null) { + $invalidProperties[] = "'message' can't be null"; + } + if ((mb_strlen($this->container['message']) > 4096)) { + $invalidProperties[] = "invalid value for 'message', the character length must be smaller than or equal to 4096."; + } + + if ((mb_strlen($this->container['message']) < 1)) { + $invalidProperties[] = "invalid value for 'message', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message Текст сообщения. + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + if ((mb_strlen($message) > 4096)) { + throw new \InvalidArgumentException('invalid length for $message when calling SendMessageToChatRequest., must be smaller than or equal to 4096.'); + } + if ((mb_strlen($message) < 1)) { + throw new \InvalidArgumentException('invalid length for $message when calling SendMessageToChatRequest., must be bigger than or equal to 1.'); + } + + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetFeedParamsRequest.php b/erp24/lib/yandex_market_api/Model/SetFeedParamsRequest.php new file mode 100644 index 00000000..45097666 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetFeedParamsRequest.php @@ -0,0 +1,413 @@ + + */ +class SetFeedParamsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetFeedParamsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'parameters' => '\OpenAPI\Client\Model\FeedParameterDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'parameters' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'parameters' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'parameters' => 'parameters' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'parameters' => 'setParameters' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'parameters' => 'getParameters' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('parameters', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['parameters'] === null) { + $invalidProperties[] = "'parameters' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets parameters + * + * @return \OpenAPI\Client\Model\FeedParameterDTO[] + */ + public function getParameters() + { + return $this->container['parameters']; + } + + /** + * Sets parameters + * + * @param \OpenAPI\Client\Model\FeedParameterDTO[] $parameters Параметры прайс-листа. Обязательный параметр. + * + * @return self + */ + public function setParameters($parameters) + { + if (is_null($parameters)) { + throw new \InvalidArgumentException('non-nullable parameters cannot be null'); + } + $this->container['parameters'] = $parameters; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetOrderBoxLayoutRequest.php b/erp24/lib/yandex_market_api/Model/SetOrderBoxLayoutRequest.php new file mode 100644 index 00000000..a45641d3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetOrderBoxLayoutRequest.php @@ -0,0 +1,455 @@ + + */ +class SetOrderBoxLayoutRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetOrderBoxLayoutRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'boxes' => '\OpenAPI\Client\Model\OrderBoxLayoutDTO[]', + 'allow_remove' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'boxes' => null, + 'allow_remove' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'boxes' => false, + 'allow_remove' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'boxes' => 'boxes', + 'allow_remove' => 'allowRemove' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'boxes' => 'setBoxes', + 'allow_remove' => 'setAllowRemove' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'boxes' => 'getBoxes', + 'allow_remove' => 'getAllowRemove' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('boxes', $data ?? [], null); + $this->setIfExists('allow_remove', $data ?? [], false); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['boxes'] === null) { + $invalidProperties[] = "'boxes' can't be null"; + } + if ((count($this->container['boxes']) < 1)) { + $invalidProperties[] = "invalid value for 'boxes', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets boxes + * + * @return \OpenAPI\Client\Model\OrderBoxLayoutDTO[] + */ + public function getBoxes() + { + return $this->container['boxes']; + } + + /** + * Sets boxes + * + * @param \OpenAPI\Client\Model\OrderBoxLayoutDTO[] $boxes Список коробок. + * + * @return self + */ + public function setBoxes($boxes) + { + if (is_null($boxes)) { + throw new \InvalidArgumentException('non-nullable boxes cannot be null'); + } + + + if ((count($boxes) < 1)) { + throw new \InvalidArgumentException('invalid length for $boxes when calling SetOrderBoxLayoutRequest., number of items must be greater than or equal to 1.'); + } + $this->container['boxes'] = $boxes; + + return $this; + } + + /** + * Gets allow_remove + * + * @return bool|null + */ + public function getAllowRemove() + { + return $this->container['allow_remove']; + } + + /** + * Sets allow_remove + * + * @param bool|null $allow_remove Передайте `true`, если вы собираетесь удалить часть товаров из заказа. + * + * @return self + */ + public function setAllowRemove($allow_remove) + { + if (is_null($allow_remove)) { + throw new \InvalidArgumentException('non-nullable allow_remove cannot be null'); + } + $this->container['allow_remove'] = $allow_remove; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetOrderBoxLayoutResponse.php b/erp24/lib/yandex_market_api/Model/SetOrderBoxLayoutResponse.php new file mode 100644 index 00000000..237deaa9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetOrderBoxLayoutResponse.php @@ -0,0 +1,443 @@ + + */ +class SetOrderBoxLayoutResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetOrderBoxLayoutResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\OrderBoxesLayoutDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\OrderBoxesLayoutDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\OrderBoxesLayoutDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetOrderDeliveryDateRequest.php b/erp24/lib/yandex_market_api/Model/SetOrderDeliveryDateRequest.php new file mode 100644 index 00000000..4a2f6f71 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetOrderDeliveryDateRequest.php @@ -0,0 +1,449 @@ + + */ +class SetOrderDeliveryDateRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetOrderDeliveryDateRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'dates' => '\OpenAPI\Client\Model\OrderDeliveryDateDTO', + 'reason' => '\OpenAPI\Client\Model\OrderDeliveryDateReasonType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'dates' => null, + 'reason' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'dates' => false, + 'reason' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'dates' => 'dates', + 'reason' => 'reason' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'dates' => 'setDates', + 'reason' => 'setReason' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'dates' => 'getDates', + 'reason' => 'getReason' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('dates', $data ?? [], null); + $this->setIfExists('reason', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['dates'] === null) { + $invalidProperties[] = "'dates' can't be null"; + } + if ($this->container['reason'] === null) { + $invalidProperties[] = "'reason' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets dates + * + * @return \OpenAPI\Client\Model\OrderDeliveryDateDTO + */ + public function getDates() + { + return $this->container['dates']; + } + + /** + * Sets dates + * + * @param \OpenAPI\Client\Model\OrderDeliveryDateDTO $dates dates + * + * @return self + */ + public function setDates($dates) + { + if (is_null($dates)) { + throw new \InvalidArgumentException('non-nullable dates cannot be null'); + } + $this->container['dates'] = $dates; + + return $this; + } + + /** + * Gets reason + * + * @return \OpenAPI\Client\Model\OrderDeliveryDateReasonType + */ + public function getReason() + { + return $this->container['reason']; + } + + /** + * Sets reason + * + * @param \OpenAPI\Client\Model\OrderDeliveryDateReasonType $reason reason + * + * @return self + */ + public function setReason($reason) + { + if (is_null($reason)) { + throw new \InvalidArgumentException('non-nullable reason cannot be null'); + } + $this->container['reason'] = $reason; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetOrderDeliveryTrackCodeRequest.php b/erp24/lib/yandex_market_api/Model/SetOrderDeliveryTrackCodeRequest.php new file mode 100644 index 00000000..5c4cd6b5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetOrderDeliveryTrackCodeRequest.php @@ -0,0 +1,449 @@ + + */ +class SetOrderDeliveryTrackCodeRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetOrderDeliveryTrackCodeRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'track_code' => 'string', + 'delivery_service_id' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'track_code' => null, + 'delivery_service_id' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'track_code' => false, + 'delivery_service_id' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'track_code' => 'trackCode', + 'delivery_service_id' => 'deliveryServiceId' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'track_code' => 'setTrackCode', + 'delivery_service_id' => 'setDeliveryServiceId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'track_code' => 'getTrackCode', + 'delivery_service_id' => 'getDeliveryServiceId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('track_code', $data ?? [], null); + $this->setIfExists('delivery_service_id', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['track_code'] === null) { + $invalidProperties[] = "'track_code' can't be null"; + } + if ($this->container['delivery_service_id'] === null) { + $invalidProperties[] = "'delivery_service_id' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets track_code + * + * @return string + */ + public function getTrackCode() + { + return $this->container['track_code']; + } + + /** + * Sets track_code + * + * @param string $track_code Трек‑номер посылки. + * + * @return self + */ + public function setTrackCode($track_code) + { + if (is_null($track_code)) { + throw new \InvalidArgumentException('non-nullable track_code cannot be null'); + } + $this->container['track_code'] = $track_code; + + return $this; + } + + /** + * Gets delivery_service_id + * + * @return int + */ + public function getDeliveryServiceId() + { + return $this->container['delivery_service_id']; + } + + /** + * Sets delivery_service_id + * + * @param int $delivery_service_id Идентификатор службы доставки. Информацию о службе доставки можно получить с помощью запроса [GET delivery/services](../../reference/orders/getDeliveryServices.md). + * + * @return self + */ + public function setDeliveryServiceId($delivery_service_id) + { + if (is_null($delivery_service_id)) { + throw new \InvalidArgumentException('non-nullable delivery_service_id cannot be null'); + } + $this->container['delivery_service_id'] = $delivery_service_id; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetOrderShipmentBoxesRequest.php b/erp24/lib/yandex_market_api/Model/SetOrderShipmentBoxesRequest.php new file mode 100644 index 00000000..a5e9ca6d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetOrderShipmentBoxesRequest.php @@ -0,0 +1,421 @@ + + */ +class SetOrderShipmentBoxesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetOrderShipmentBoxesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'boxes' => '\OpenAPI\Client\Model\ParcelBoxDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'boxes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'boxes' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'boxes' => 'boxes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'boxes' => 'setBoxes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'boxes' => 'getBoxes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('boxes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['boxes'] === null) { + $invalidProperties[] = "'boxes' can't be null"; + } + if ((count($this->container['boxes']) < 1)) { + $invalidProperties[] = "invalid value for 'boxes', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets boxes + * + * @return \OpenAPI\Client\Model\ParcelBoxDTO[] + */ + public function getBoxes() + { + return $this->container['boxes']; + } + + /** + * Sets boxes + * + * @param \OpenAPI\Client\Model\ParcelBoxDTO[] $boxes Список грузовых мест. Маркет определяет количество мест по длине этого списка. + * + * @return self + */ + public function setBoxes($boxes) + { + if (is_null($boxes)) { + throw new \InvalidArgumentException('non-nullable boxes cannot be null'); + } + + + if ((count($boxes) < 1)) { + throw new \InvalidArgumentException('invalid length for $boxes when calling SetOrderShipmentBoxesRequest., number of items must be greater than or equal to 1.'); + } + $this->container['boxes'] = $boxes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetOrderShipmentBoxesResponse.php b/erp24/lib/yandex_market_api/Model/SetOrderShipmentBoxesResponse.php new file mode 100644 index 00000000..7c6bf595 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetOrderShipmentBoxesResponse.php @@ -0,0 +1,443 @@ + + */ +class SetOrderShipmentBoxesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetOrderShipmentBoxesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\ShipmentBoxesDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\ShipmentBoxesDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\ShipmentBoxesDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetReturnDecisionRequest.php b/erp24/lib/yandex_market_api/Model/SetReturnDecisionRequest.php new file mode 100644 index 00000000..c0a8c02d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetReturnDecisionRequest.php @@ -0,0 +1,484 @@ + + */ +class SetReturnDecisionRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetReturnDecisionRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'return_item_id' => 'int', + 'decision_type' => '\OpenAPI\Client\Model\ReturnRequestDecisionType', + 'comment' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'return_item_id' => 'int64', + 'decision_type' => null, + 'comment' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'return_item_id' => false, + 'decision_type' => false, + 'comment' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'return_item_id' => 'returnItemId', + 'decision_type' => 'decisionType', + 'comment' => 'comment' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'return_item_id' => 'setReturnItemId', + 'decision_type' => 'setDecisionType', + 'comment' => 'setComment' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'return_item_id' => 'getReturnItemId', + 'decision_type' => 'getDecisionType', + 'comment' => 'getComment' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('return_item_id', $data ?? [], null); + $this->setIfExists('decision_type', $data ?? [], null); + $this->setIfExists('comment', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['return_item_id'] === null) { + $invalidProperties[] = "'return_item_id' can't be null"; + } + if ($this->container['decision_type'] === null) { + $invalidProperties[] = "'decision_type' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets return_item_id + * + * @return int + */ + public function getReturnItemId() + { + return $this->container['return_item_id']; + } + + /** + * Sets return_item_id + * + * @param int $return_item_id Идентификатор товара в возврате. + * + * @return self + */ + public function setReturnItemId($return_item_id) + { + if (is_null($return_item_id)) { + throw new \InvalidArgumentException('non-nullable return_item_id cannot be null'); + } + $this->container['return_item_id'] = $return_item_id; + + return $this; + } + + /** + * Gets decision_type + * + * @return \OpenAPI\Client\Model\ReturnRequestDecisionType + */ + public function getDecisionType() + { + return $this->container['decision_type']; + } + + /** + * Sets decision_type + * + * @param \OpenAPI\Client\Model\ReturnRequestDecisionType $decision_type decision_type + * + * @return self + */ + public function setDecisionType($decision_type) + { + if (is_null($decision_type)) { + throw new \InvalidArgumentException('non-nullable decision_type cannot be null'); + } + $this->container['decision_type'] = $decision_type; + + return $this; + } + + /** + * Gets comment + * + * @return string|null + */ + public function getComment() + { + return $this->container['comment']; + } + + /** + * Sets comment + * + * @param string|null $comment Комментарий к решению. Укажите: * для `REFUND_MONEY_INCLUDING_SHIPMENT`— стоимость обратной пересылки; * для `REPAIR` — когда вы устраните недостатки товара; * для `DECLINE_REFUND` — причину отказа; * для `OTHER_DECISION` — какое решение вы предлагаете. + * + * @return self + */ + public function setComment($comment) + { + if (is_null($comment)) { + throw new \InvalidArgumentException('non-nullable comment cannot be null'); + } + $this->container['comment'] = $comment; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SetShipmentPalletsCountRequest.php b/erp24/lib/yandex_market_api/Model/SetShipmentPalletsCountRequest.php new file mode 100644 index 00000000..0e7c5586 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SetShipmentPalletsCountRequest.php @@ -0,0 +1,422 @@ + + */ +class SetShipmentPalletsCountRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SetShipmentPalletsCountRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'places_count' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'places_count' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'places_count' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'places_count' => 'placesCount' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'places_count' => 'setPlacesCount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'places_count' => 'getPlacesCount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('places_count', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['places_count'] === null) { + $invalidProperties[] = "'places_count' can't be null"; + } + if (($this->container['places_count'] < 0)) { + $invalidProperties[] = "invalid value for 'places_count', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets places_count + * + * @return int + */ + public function getPlacesCount() + { + return $this->container['places_count']; + } + + /** + * Sets places_count + * + * @param int $places_count Количество упаковок в отгрузке. + * + * @return self + */ + public function setPlacesCount($places_count) + { + if (is_null($places_count)) { + throw new \InvalidArgumentException('non-nullable places_count cannot be null'); + } + + if (($places_count < 0)) { + throw new \InvalidArgumentException('invalid value for $places_count when calling SetShipmentPalletsCountRequest., must be bigger than or equal to 0.'); + } + + $this->container['places_count'] = $places_count; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ShelfsStatisticsAttributionType.php b/erp24/lib/yandex_market_api/Model/ShelfsStatisticsAttributionType.php new file mode 100644 index 00000000..bae458e7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ShelfsStatisticsAttributionType.php @@ -0,0 +1,63 @@ + + */ +class ShipmentBoxesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ShipmentBoxesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'boxes' => '\OpenAPI\Client\Model\ParcelBoxDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'boxes' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'boxes' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'boxes' => 'boxes' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'boxes' => 'setBoxes' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'boxes' => 'getBoxes' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('boxes', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['boxes'] === null) { + $invalidProperties[] = "'boxes' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets boxes + * + * @return \OpenAPI\Client\Model\ParcelBoxDTO[] + */ + public function getBoxes() + { + return $this->container['boxes']; + } + + /** + * Sets boxes + * + * @param \OpenAPI\Client\Model\ParcelBoxDTO[] $boxes Список грузовых мест. Маркет определил количество мест по длине этого списка. + * + * @return self + */ + public function setBoxes($boxes) + { + if (is_null($boxes)) { + throw new \InvalidArgumentException('non-nullable boxes cannot be null'); + } + $this->container['boxes'] = $boxes; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ShipmentDTO.php b/erp24/lib/yandex_market_api/Model/ShipmentDTO.php new file mode 100644 index 00000000..9b32674e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ShipmentDTO.php @@ -0,0 +1,950 @@ + + */ +class ShipmentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ShipmentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'plan_interval_from' => '\DateTime', + 'plan_interval_to' => '\DateTime', + 'shipment_type' => '\OpenAPI\Client\Model\ShipmentType', + 'warehouse' => '\OpenAPI\Client\Model\PartnerShipmentWarehouseDTO', + 'warehouse_to' => '\OpenAPI\Client\Model\PartnerShipmentWarehouseDTO', + 'external_id' => 'string', + 'delivery_service' => '\OpenAPI\Client\Model\DeliveryServiceDTO', + 'pallets_count' => '\OpenAPI\Client\Model\PalletsCountDTO', + 'order_ids' => 'int[]', + 'draft_count' => 'int', + 'planned_count' => 'int', + 'fact_count' => 'int', + 'current_status' => '\OpenAPI\Client\Model\ShipmentStatusChangeDTO', + 'available_actions' => '\OpenAPI\Client\Model\ShipmentActionType[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'plan_interval_from' => 'date-time', + 'plan_interval_to' => 'date-time', + 'shipment_type' => null, + 'warehouse' => null, + 'warehouse_to' => null, + 'external_id' => null, + 'delivery_service' => null, + 'pallets_count' => null, + 'order_ids' => 'int64', + 'draft_count' => 'int32', + 'planned_count' => 'int32', + 'fact_count' => 'int32', + 'current_status' => null, + 'available_actions' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'plan_interval_from' => false, + 'plan_interval_to' => false, + 'shipment_type' => false, + 'warehouse' => false, + 'warehouse_to' => false, + 'external_id' => false, + 'delivery_service' => false, + 'pallets_count' => false, + 'order_ids' => false, + 'draft_count' => false, + 'planned_count' => false, + 'fact_count' => false, + 'current_status' => false, + 'available_actions' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'plan_interval_from' => 'planIntervalFrom', + 'plan_interval_to' => 'planIntervalTo', + 'shipment_type' => 'shipmentType', + 'warehouse' => 'warehouse', + 'warehouse_to' => 'warehouseTo', + 'external_id' => 'externalId', + 'delivery_service' => 'deliveryService', + 'pallets_count' => 'palletsCount', + 'order_ids' => 'orderIds', + 'draft_count' => 'draftCount', + 'planned_count' => 'plannedCount', + 'fact_count' => 'factCount', + 'current_status' => 'currentStatus', + 'available_actions' => 'availableActions' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'plan_interval_from' => 'setPlanIntervalFrom', + 'plan_interval_to' => 'setPlanIntervalTo', + 'shipment_type' => 'setShipmentType', + 'warehouse' => 'setWarehouse', + 'warehouse_to' => 'setWarehouseTo', + 'external_id' => 'setExternalId', + 'delivery_service' => 'setDeliveryService', + 'pallets_count' => 'setPalletsCount', + 'order_ids' => 'setOrderIds', + 'draft_count' => 'setDraftCount', + 'planned_count' => 'setPlannedCount', + 'fact_count' => 'setFactCount', + 'current_status' => 'setCurrentStatus', + 'available_actions' => 'setAvailableActions' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'plan_interval_from' => 'getPlanIntervalFrom', + 'plan_interval_to' => 'getPlanIntervalTo', + 'shipment_type' => 'getShipmentType', + 'warehouse' => 'getWarehouse', + 'warehouse_to' => 'getWarehouseTo', + 'external_id' => 'getExternalId', + 'delivery_service' => 'getDeliveryService', + 'pallets_count' => 'getPalletsCount', + 'order_ids' => 'getOrderIds', + 'draft_count' => 'getDraftCount', + 'planned_count' => 'getPlannedCount', + 'fact_count' => 'getFactCount', + 'current_status' => 'getCurrentStatus', + 'available_actions' => 'getAvailableActions' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('plan_interval_from', $data ?? [], null); + $this->setIfExists('plan_interval_to', $data ?? [], null); + $this->setIfExists('shipment_type', $data ?? [], null); + $this->setIfExists('warehouse', $data ?? [], null); + $this->setIfExists('warehouse_to', $data ?? [], null); + $this->setIfExists('external_id', $data ?? [], null); + $this->setIfExists('delivery_service', $data ?? [], null); + $this->setIfExists('pallets_count', $data ?? [], null); + $this->setIfExists('order_ids', $data ?? [], null); + $this->setIfExists('draft_count', $data ?? [], null); + $this->setIfExists('planned_count', $data ?? [], null); + $this->setIfExists('fact_count', $data ?? [], null); + $this->setIfExists('current_status', $data ?? [], null); + $this->setIfExists('available_actions', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if (($this->container['id'] < 1)) { + $invalidProperties[] = "invalid value for 'id', must be bigger than or equal to 1."; + } + + if ($this->container['plan_interval_from'] === null) { + $invalidProperties[] = "'plan_interval_from' can't be null"; + } + if ($this->container['plan_interval_to'] === null) { + $invalidProperties[] = "'plan_interval_to' can't be null"; + } + if ($this->container['order_ids'] === null) { + $invalidProperties[] = "'order_ids' can't be null"; + } + if ($this->container['draft_count'] === null) { + $invalidProperties[] = "'draft_count' can't be null"; + } + if (($this->container['draft_count'] < 0)) { + $invalidProperties[] = "invalid value for 'draft_count', must be bigger than or equal to 0."; + } + + if ($this->container['planned_count'] === null) { + $invalidProperties[] = "'planned_count' can't be null"; + } + if (($this->container['planned_count'] < 0)) { + $invalidProperties[] = "invalid value for 'planned_count', must be bigger than or equal to 0."; + } + + if ($this->container['fact_count'] === null) { + $invalidProperties[] = "'fact_count' can't be null"; + } + if (($this->container['fact_count'] < 0)) { + $invalidProperties[] = "invalid value for 'fact_count', must be bigger than or equal to 0."; + } + + if ($this->container['available_actions'] === null) { + $invalidProperties[] = "'available_actions' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор отгрузки. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + if (($id < 1)) { + throw new \InvalidArgumentException('invalid value for $id when calling ShipmentDTO., must be bigger than or equal to 1.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets plan_interval_from + * + * @return \DateTime + */ + public function getPlanIntervalFrom() + { + return $this->container['plan_interval_from']; + } + + /** + * Sets plan_interval_from + * + * @param \DateTime $plan_interval_from Начало планового интервала отгрузки. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setPlanIntervalFrom($plan_interval_from) + { + if (is_null($plan_interval_from)) { + throw new \InvalidArgumentException('non-nullable plan_interval_from cannot be null'); + } + $this->container['plan_interval_from'] = $plan_interval_from; + + return $this; + } + + /** + * Gets plan_interval_to + * + * @return \DateTime + */ + public function getPlanIntervalTo() + { + return $this->container['plan_interval_to']; + } + + /** + * Sets plan_interval_to + * + * @param \DateTime $plan_interval_to Конец планового интервала отгрузки. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setPlanIntervalTo($plan_interval_to) + { + if (is_null($plan_interval_to)) { + throw new \InvalidArgumentException('non-nullable plan_interval_to cannot be null'); + } + $this->container['plan_interval_to'] = $plan_interval_to; + + return $this; + } + + /** + * Gets shipment_type + * + * @return \OpenAPI\Client\Model\ShipmentType|null + */ + public function getShipmentType() + { + return $this->container['shipment_type']; + } + + /** + * Sets shipment_type + * + * @param \OpenAPI\Client\Model\ShipmentType|null $shipment_type shipment_type + * + * @return self + */ + public function setShipmentType($shipment_type) + { + if (is_null($shipment_type)) { + throw new \InvalidArgumentException('non-nullable shipment_type cannot be null'); + } + $this->container['shipment_type'] = $shipment_type; + + return $this; + } + + /** + * Gets warehouse + * + * @return \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null + */ + public function getWarehouse() + { + return $this->container['warehouse']; + } + + /** + * Sets warehouse + * + * @param \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null $warehouse warehouse + * + * @return self + */ + public function setWarehouse($warehouse) + { + if (is_null($warehouse)) { + throw new \InvalidArgumentException('non-nullable warehouse cannot be null'); + } + $this->container['warehouse'] = $warehouse; + + return $this; + } + + /** + * Gets warehouse_to + * + * @return \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null + */ + public function getWarehouseTo() + { + return $this->container['warehouse_to']; + } + + /** + * Sets warehouse_to + * + * @param \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null $warehouse_to warehouse_to + * + * @return self + */ + public function setWarehouseTo($warehouse_to) + { + if (is_null($warehouse_to)) { + throw new \InvalidArgumentException('non-nullable warehouse_to cannot be null'); + } + $this->container['warehouse_to'] = $warehouse_to; + + return $this; + } + + /** + * Gets external_id + * + * @return string|null + */ + public function getExternalId() + { + return $this->container['external_id']; + } + + /** + * Sets external_id + * + * @param string|null $external_id Идентификатор отгрузки в вашей системе. Если вы еще не передавали идентификатор, вернется идентификатор из параметра `id`. + * + * @return self + */ + public function setExternalId($external_id) + { + if (is_null($external_id)) { + throw new \InvalidArgumentException('non-nullable external_id cannot be null'); + } + $this->container['external_id'] = $external_id; + + return $this; + } + + /** + * Gets delivery_service + * + * @return \OpenAPI\Client\Model\DeliveryServiceDTO|null + */ + public function getDeliveryService() + { + return $this->container['delivery_service']; + } + + /** + * Sets delivery_service + * + * @param \OpenAPI\Client\Model\DeliveryServiceDTO|null $delivery_service delivery_service + * + * @return self + */ + public function setDeliveryService($delivery_service) + { + if (is_null($delivery_service)) { + throw new \InvalidArgumentException('non-nullable delivery_service cannot be null'); + } + $this->container['delivery_service'] = $delivery_service; + + return $this; + } + + /** + * Gets pallets_count + * + * @return \OpenAPI\Client\Model\PalletsCountDTO|null + */ + public function getPalletsCount() + { + return $this->container['pallets_count']; + } + + /** + * Sets pallets_count + * + * @param \OpenAPI\Client\Model\PalletsCountDTO|null $pallets_count pallets_count + * + * @return self + */ + public function setPalletsCount($pallets_count) + { + if (is_null($pallets_count)) { + throw new \InvalidArgumentException('non-nullable pallets_count cannot be null'); + } + $this->container['pallets_count'] = $pallets_count; + + return $this; + } + + /** + * Gets order_ids + * + * @return int[] + */ + public function getOrderIds() + { + return $this->container['order_ids']; + } + + /** + * Sets order_ids + * + * @param int[] $order_ids Идентификаторы заказов в отгрузке. + * + * @return self + */ + public function setOrderIds($order_ids) + { + if (is_null($order_ids)) { + throw new \InvalidArgumentException('non-nullable order_ids cannot be null'); + } + + + $this->container['order_ids'] = $order_ids; + + return $this; + } + + /** + * Gets draft_count + * + * @return int + */ + public function getDraftCount() + { + return $this->container['draft_count']; + } + + /** + * Sets draft_count + * + * @param int $draft_count Количество заказов, которое Маркет запланировал к отгрузке. + * + * @return self + */ + public function setDraftCount($draft_count) + { + if (is_null($draft_count)) { + throw new \InvalidArgumentException('non-nullable draft_count cannot be null'); + } + + if (($draft_count < 0)) { + throw new \InvalidArgumentException('invalid value for $draft_count when calling ShipmentDTO., must be bigger than or equal to 0.'); + } + + $this->container['draft_count'] = $draft_count; + + return $this; + } + + /** + * Gets planned_count + * + * @return int + */ + public function getPlannedCount() + { + return $this->container['planned_count']; + } + + /** + * Sets planned_count + * + * @param int $planned_count Количество заказов, которое Маркет подтвердил к отгрузке. + * + * @return self + */ + public function setPlannedCount($planned_count) + { + if (is_null($planned_count)) { + throw new \InvalidArgumentException('non-nullable planned_count cannot be null'); + } + + if (($planned_count < 0)) { + throw new \InvalidArgumentException('invalid value for $planned_count when calling ShipmentDTO., must be bigger than or equal to 0.'); + } + + $this->container['planned_count'] = $planned_count; + + return $this; + } + + /** + * Gets fact_count + * + * @return int + */ + public function getFactCount() + { + return $this->container['fact_count']; + } + + /** + * Sets fact_count + * + * @param int $fact_count Количество заказов, принятых в сортировочном центре или пункте приема. + * + * @return self + */ + public function setFactCount($fact_count) + { + if (is_null($fact_count)) { + throw new \InvalidArgumentException('non-nullable fact_count cannot be null'); + } + + if (($fact_count < 0)) { + throw new \InvalidArgumentException('invalid value for $fact_count when calling ShipmentDTO., must be bigger than or equal to 0.'); + } + + $this->container['fact_count'] = $fact_count; + + return $this; + } + + /** + * Gets current_status + * + * @return \OpenAPI\Client\Model\ShipmentStatusChangeDTO|null + */ + public function getCurrentStatus() + { + return $this->container['current_status']; + } + + /** + * Sets current_status + * + * @param \OpenAPI\Client\Model\ShipmentStatusChangeDTO|null $current_status current_status + * + * @return self + */ + public function setCurrentStatus($current_status) + { + if (is_null($current_status)) { + throw new \InvalidArgumentException('non-nullable current_status cannot be null'); + } + $this->container['current_status'] = $current_status; + + return $this; + } + + /** + * Gets available_actions + * + * @return \OpenAPI\Client\Model\ShipmentActionType[] + */ + public function getAvailableActions() + { + return $this->container['available_actions']; + } + + /** + * Sets available_actions + * + * @param \OpenAPI\Client\Model\ShipmentActionType[] $available_actions Доступные действия над отгрузкой. + * + * @return self + */ + public function setAvailableActions($available_actions) + { + if (is_null($available_actions)) { + throw new \InvalidArgumentException('non-nullable available_actions cannot be null'); + } + + + $this->container['available_actions'] = $available_actions; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ShipmentInfoDTO.php b/erp24/lib/yandex_market_api/Model/ShipmentInfoDTO.php new file mode 100644 index 00000000..d3a3f798 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ShipmentInfoDTO.php @@ -0,0 +1,979 @@ + + */ +class ShipmentInfoDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ShipmentInfoDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'plan_interval_from' => '\DateTime', + 'plan_interval_to' => '\DateTime', + 'shipment_type' => '\OpenAPI\Client\Model\ShipmentType', + 'warehouse' => '\OpenAPI\Client\Model\PartnerShipmentWarehouseDTO', + 'warehouse_to' => '\OpenAPI\Client\Model\PartnerShipmentWarehouseDTO', + 'external_id' => 'string', + 'delivery_service' => '\OpenAPI\Client\Model\DeliveryServiceDTO', + 'pallets_count' => '\OpenAPI\Client\Model\PalletsCountDTO', + 'order_ids' => 'int[]', + 'draft_count' => 'int', + 'planned_count' => 'int', + 'fact_count' => 'int', + 'status' => '\OpenAPI\Client\Model\ShipmentStatusType', + 'status_description' => 'string', + 'status_update_time' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'plan_interval_from' => 'date-time', + 'plan_interval_to' => 'date-time', + 'shipment_type' => null, + 'warehouse' => null, + 'warehouse_to' => null, + 'external_id' => null, + 'delivery_service' => null, + 'pallets_count' => null, + 'order_ids' => 'int64', + 'draft_count' => 'int32', + 'planned_count' => 'int32', + 'fact_count' => 'int32', + 'status' => null, + 'status_description' => null, + 'status_update_time' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'plan_interval_from' => false, + 'plan_interval_to' => false, + 'shipment_type' => false, + 'warehouse' => false, + 'warehouse_to' => false, + 'external_id' => false, + 'delivery_service' => false, + 'pallets_count' => false, + 'order_ids' => false, + 'draft_count' => false, + 'planned_count' => false, + 'fact_count' => false, + 'status' => false, + 'status_description' => false, + 'status_update_time' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'plan_interval_from' => 'planIntervalFrom', + 'plan_interval_to' => 'planIntervalTo', + 'shipment_type' => 'shipmentType', + 'warehouse' => 'warehouse', + 'warehouse_to' => 'warehouseTo', + 'external_id' => 'externalId', + 'delivery_service' => 'deliveryService', + 'pallets_count' => 'palletsCount', + 'order_ids' => 'orderIds', + 'draft_count' => 'draftCount', + 'planned_count' => 'plannedCount', + 'fact_count' => 'factCount', + 'status' => 'status', + 'status_description' => 'statusDescription', + 'status_update_time' => 'statusUpdateTime' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'plan_interval_from' => 'setPlanIntervalFrom', + 'plan_interval_to' => 'setPlanIntervalTo', + 'shipment_type' => 'setShipmentType', + 'warehouse' => 'setWarehouse', + 'warehouse_to' => 'setWarehouseTo', + 'external_id' => 'setExternalId', + 'delivery_service' => 'setDeliveryService', + 'pallets_count' => 'setPalletsCount', + 'order_ids' => 'setOrderIds', + 'draft_count' => 'setDraftCount', + 'planned_count' => 'setPlannedCount', + 'fact_count' => 'setFactCount', + 'status' => 'setStatus', + 'status_description' => 'setStatusDescription', + 'status_update_time' => 'setStatusUpdateTime' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'plan_interval_from' => 'getPlanIntervalFrom', + 'plan_interval_to' => 'getPlanIntervalTo', + 'shipment_type' => 'getShipmentType', + 'warehouse' => 'getWarehouse', + 'warehouse_to' => 'getWarehouseTo', + 'external_id' => 'getExternalId', + 'delivery_service' => 'getDeliveryService', + 'pallets_count' => 'getPalletsCount', + 'order_ids' => 'getOrderIds', + 'draft_count' => 'getDraftCount', + 'planned_count' => 'getPlannedCount', + 'fact_count' => 'getFactCount', + 'status' => 'getStatus', + 'status_description' => 'getStatusDescription', + 'status_update_time' => 'getStatusUpdateTime' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('plan_interval_from', $data ?? [], null); + $this->setIfExists('plan_interval_to', $data ?? [], null); + $this->setIfExists('shipment_type', $data ?? [], null); + $this->setIfExists('warehouse', $data ?? [], null); + $this->setIfExists('warehouse_to', $data ?? [], null); + $this->setIfExists('external_id', $data ?? [], null); + $this->setIfExists('delivery_service', $data ?? [], null); + $this->setIfExists('pallets_count', $data ?? [], null); + $this->setIfExists('order_ids', $data ?? [], null); + $this->setIfExists('draft_count', $data ?? [], null); + $this->setIfExists('planned_count', $data ?? [], null); + $this->setIfExists('fact_count', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('status_description', $data ?? [], null); + $this->setIfExists('status_update_time', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if (($this->container['id'] < 1)) { + $invalidProperties[] = "invalid value for 'id', must be bigger than or equal to 1."; + } + + if ($this->container['plan_interval_from'] === null) { + $invalidProperties[] = "'plan_interval_from' can't be null"; + } + if ($this->container['plan_interval_to'] === null) { + $invalidProperties[] = "'plan_interval_to' can't be null"; + } + if ($this->container['order_ids'] === null) { + $invalidProperties[] = "'order_ids' can't be null"; + } + if ($this->container['draft_count'] === null) { + $invalidProperties[] = "'draft_count' can't be null"; + } + if (($this->container['draft_count'] < 0)) { + $invalidProperties[] = "invalid value for 'draft_count', must be bigger than or equal to 0."; + } + + if ($this->container['planned_count'] === null) { + $invalidProperties[] = "'planned_count' can't be null"; + } + if (($this->container['planned_count'] < 0)) { + $invalidProperties[] = "invalid value for 'planned_count', must be bigger than or equal to 0."; + } + + if ($this->container['fact_count'] === null) { + $invalidProperties[] = "'fact_count' can't be null"; + } + if (($this->container['fact_count'] < 0)) { + $invalidProperties[] = "invalid value for 'fact_count', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор отгрузки. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + + if (($id < 1)) { + throw new \InvalidArgumentException('invalid value for $id when calling ShipmentInfoDTO., must be bigger than or equal to 1.'); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets plan_interval_from + * + * @return \DateTime + */ + public function getPlanIntervalFrom() + { + return $this->container['plan_interval_from']; + } + + /** + * Sets plan_interval_from + * + * @param \DateTime $plan_interval_from Начало планового интервала отгрузки. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setPlanIntervalFrom($plan_interval_from) + { + if (is_null($plan_interval_from)) { + throw new \InvalidArgumentException('non-nullable plan_interval_from cannot be null'); + } + $this->container['plan_interval_from'] = $plan_interval_from; + + return $this; + } + + /** + * Gets plan_interval_to + * + * @return \DateTime + */ + public function getPlanIntervalTo() + { + return $this->container['plan_interval_to']; + } + + /** + * Sets plan_interval_to + * + * @param \DateTime $plan_interval_to Конец планового интервала отгрузки. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setPlanIntervalTo($plan_interval_to) + { + if (is_null($plan_interval_to)) { + throw new \InvalidArgumentException('non-nullable plan_interval_to cannot be null'); + } + $this->container['plan_interval_to'] = $plan_interval_to; + + return $this; + } + + /** + * Gets shipment_type + * + * @return \OpenAPI\Client\Model\ShipmentType|null + */ + public function getShipmentType() + { + return $this->container['shipment_type']; + } + + /** + * Sets shipment_type + * + * @param \OpenAPI\Client\Model\ShipmentType|null $shipment_type shipment_type + * + * @return self + */ + public function setShipmentType($shipment_type) + { + if (is_null($shipment_type)) { + throw new \InvalidArgumentException('non-nullable shipment_type cannot be null'); + } + $this->container['shipment_type'] = $shipment_type; + + return $this; + } + + /** + * Gets warehouse + * + * @return \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null + */ + public function getWarehouse() + { + return $this->container['warehouse']; + } + + /** + * Sets warehouse + * + * @param \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null $warehouse warehouse + * + * @return self + */ + public function setWarehouse($warehouse) + { + if (is_null($warehouse)) { + throw new \InvalidArgumentException('non-nullable warehouse cannot be null'); + } + $this->container['warehouse'] = $warehouse; + + return $this; + } + + /** + * Gets warehouse_to + * + * @return \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null + */ + public function getWarehouseTo() + { + return $this->container['warehouse_to']; + } + + /** + * Sets warehouse_to + * + * @param \OpenAPI\Client\Model\PartnerShipmentWarehouseDTO|null $warehouse_to warehouse_to + * + * @return self + */ + public function setWarehouseTo($warehouse_to) + { + if (is_null($warehouse_to)) { + throw new \InvalidArgumentException('non-nullable warehouse_to cannot be null'); + } + $this->container['warehouse_to'] = $warehouse_to; + + return $this; + } + + /** + * Gets external_id + * + * @return string|null + */ + public function getExternalId() + { + return $this->container['external_id']; + } + + /** + * Sets external_id + * + * @param string|null $external_id Идентификатор отгрузки в вашей системе. Если вы еще не передавали идентификатор, вернется идентификатор из параметра `id`. + * + * @return self + */ + public function setExternalId($external_id) + { + if (is_null($external_id)) { + throw new \InvalidArgumentException('non-nullable external_id cannot be null'); + } + $this->container['external_id'] = $external_id; + + return $this; + } + + /** + * Gets delivery_service + * + * @return \OpenAPI\Client\Model\DeliveryServiceDTO|null + */ + public function getDeliveryService() + { + return $this->container['delivery_service']; + } + + /** + * Sets delivery_service + * + * @param \OpenAPI\Client\Model\DeliveryServiceDTO|null $delivery_service delivery_service + * + * @return self + */ + public function setDeliveryService($delivery_service) + { + if (is_null($delivery_service)) { + throw new \InvalidArgumentException('non-nullable delivery_service cannot be null'); + } + $this->container['delivery_service'] = $delivery_service; + + return $this; + } + + /** + * Gets pallets_count + * + * @return \OpenAPI\Client\Model\PalletsCountDTO|null + */ + public function getPalletsCount() + { + return $this->container['pallets_count']; + } + + /** + * Sets pallets_count + * + * @param \OpenAPI\Client\Model\PalletsCountDTO|null $pallets_count pallets_count + * + * @return self + */ + public function setPalletsCount($pallets_count) + { + if (is_null($pallets_count)) { + throw new \InvalidArgumentException('non-nullable pallets_count cannot be null'); + } + $this->container['pallets_count'] = $pallets_count; + + return $this; + } + + /** + * Gets order_ids + * + * @return int[] + */ + public function getOrderIds() + { + return $this->container['order_ids']; + } + + /** + * Sets order_ids + * + * @param int[] $order_ids Идентификаторы заказов в отгрузке. + * + * @return self + */ + public function setOrderIds($order_ids) + { + if (is_null($order_ids)) { + throw new \InvalidArgumentException('non-nullable order_ids cannot be null'); + } + + + $this->container['order_ids'] = $order_ids; + + return $this; + } + + /** + * Gets draft_count + * + * @return int + */ + public function getDraftCount() + { + return $this->container['draft_count']; + } + + /** + * Sets draft_count + * + * @param int $draft_count Количество заказов, которое Маркет запланировал к отгрузке. + * + * @return self + */ + public function setDraftCount($draft_count) + { + if (is_null($draft_count)) { + throw new \InvalidArgumentException('non-nullable draft_count cannot be null'); + } + + if (($draft_count < 0)) { + throw new \InvalidArgumentException('invalid value for $draft_count when calling ShipmentInfoDTO., must be bigger than or equal to 0.'); + } + + $this->container['draft_count'] = $draft_count; + + return $this; + } + + /** + * Gets planned_count + * + * @return int + */ + public function getPlannedCount() + { + return $this->container['planned_count']; + } + + /** + * Sets planned_count + * + * @param int $planned_count Количество заказов, которое Маркет подтвердил к отгрузке. + * + * @return self + */ + public function setPlannedCount($planned_count) + { + if (is_null($planned_count)) { + throw new \InvalidArgumentException('non-nullable planned_count cannot be null'); + } + + if (($planned_count < 0)) { + throw new \InvalidArgumentException('invalid value for $planned_count when calling ShipmentInfoDTO., must be bigger than or equal to 0.'); + } + + $this->container['planned_count'] = $planned_count; + + return $this; + } + + /** + * Gets fact_count + * + * @return int + */ + public function getFactCount() + { + return $this->container['fact_count']; + } + + /** + * Sets fact_count + * + * @param int $fact_count Количество заказов, принятых в сортировочном центре или пункте приема. + * + * @return self + */ + public function setFactCount($fact_count) + { + if (is_null($fact_count)) { + throw new \InvalidArgumentException('non-nullable fact_count cannot be null'); + } + + if (($fact_count < 0)) { + throw new \InvalidArgumentException('invalid value for $fact_count when calling ShipmentInfoDTO., must be bigger than or equal to 0.'); + } + + $this->container['fact_count'] = $fact_count; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ShipmentStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ShipmentStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets status_description + * + * @return string|null + */ + public function getStatusDescription() + { + return $this->container['status_description']; + } + + /** + * Sets status_description + * + * @param string|null $status_description Описание статуса отгрузки. + * + * @return self + */ + public function setStatusDescription($status_description) + { + if (is_null($status_description)) { + throw new \InvalidArgumentException('non-nullable status_description cannot be null'); + } + $this->container['status_description'] = $status_description; + + return $this; + } + + /** + * Gets status_update_time + * + * @return \DateTime|null + */ + public function getStatusUpdateTime() + { + return $this->container['status_update_time']; + } + + /** + * Sets status_update_time + * + * @param \DateTime|null $status_update_time Время последнего изменения статуса отгрузки Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setStatusUpdateTime($status_update_time) + { + if (is_null($status_update_time)) { + throw new \InvalidArgumentException('non-nullable status_update_time cannot be null'); + } + $this->container['status_update_time'] = $status_update_time; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ShipmentPalletLabelPageFormatType.php b/erp24/lib/yandex_market_api/Model/ShipmentPalletLabelPageFormatType.php new file mode 100644 index 00000000..16e30992 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ShipmentPalletLabelPageFormatType.php @@ -0,0 +1,63 @@ + + */ +class ShipmentStatusChangeDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ShipmentStatusChangeDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ShipmentStatusType', + 'description' => 'string', + 'update_time' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'description' => null, + 'update_time' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'description' => false, + 'update_time' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'description' => 'description', + 'update_time' => 'updateTime' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'description' => 'setDescription', + 'update_time' => 'setUpdateTime' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'description' => 'getDescription', + 'update_time' => 'getUpdateTime' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('update_time', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ShipmentStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ShipmentStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Описание статуса отгрузки. + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets update_time + * + * @return \DateTime|null + */ + public function getUpdateTime() + { + return $this->container['update_time']; + } + + /** + * Sets update_time + * + * @param \DateTime|null $update_time Время последнего изменения статуса отгрузки. Формат даты: ISO 8601 со смещением относительно UTC. + * + * @return self + */ + public function setUpdateTime($update_time) + { + if (is_null($update_time)) { + throw new \InvalidArgumentException('non-nullable update_time cannot be null'); + } + $this->container['update_time'] = $update_time; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ShipmentStatusType.php b/erp24/lib/yandex_market_api/Model/ShipmentStatusType.php new file mode 100644 index 00000000..d7b591ce --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ShipmentStatusType.php @@ -0,0 +1,81 @@ + + */ +class SkipGoodsFeedbackReactionRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SkipGoodsFeedbackReactionRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feedback_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feedback_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feedback_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'feedback_ids' => 'feedbackIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feedback_ids' => 'setFeedbackIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feedback_ids' => 'getFeedbackIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('feedback_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['feedback_ids'] === null) { + $invalidProperties[] = "'feedback_ids' can't be null"; + } + if ((count($this->container['feedback_ids']) > 50)) { + $invalidProperties[] = "invalid value for 'feedback_ids', number of items must be less than or equal to 50."; + } + + if ((count($this->container['feedback_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'feedback_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets feedback_ids + * + * @return int[] + */ + public function getFeedbackIds() + { + return $this->container['feedback_ids']; + } + + /** + * Sets feedback_ids + * + * @param int[] $feedback_ids Список идентификаторов отзывов, на которые магазин не будет отвечать. + * + * @return self + */ + public function setFeedbackIds($feedback_ids) + { + if (is_null($feedback_ids)) { + throw new \InvalidArgumentException('non-nullable feedback_ids cannot be null'); + } + + if ((count($feedback_ids) > 50)) { + throw new \InvalidArgumentException('invalid value for $feedback_ids when calling SkipGoodsFeedbackReactionRequest., number of items must be less than or equal to 50.'); + } + if ((count($feedback_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $feedback_ids when calling SkipGoodsFeedbackReactionRequest., number of items must be greater than or equal to 1.'); + } + $this->container['feedback_ids'] = $feedback_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SkuBidItemDTO.php b/erp24/lib/yandex_market_api/Model/SkuBidItemDTO.php new file mode 100644 index 00000000..1163f8d9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SkuBidItemDTO.php @@ -0,0 +1,488 @@ + + */ +class SkuBidItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SkuBidItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'sku' => 'string', + 'bid' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'sku' => null, + 'bid' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'sku' => false, + 'bid' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'sku' => 'sku', + 'bid' => 'bid' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'sku' => 'setSku', + 'bid' => 'setBid' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'sku' => 'getSku', + 'bid' => 'getBid' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('sku', $data ?? [], null); + $this->setIfExists('bid', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['sku'] === null) { + $invalidProperties[] = "'sku' can't be null"; + } + if ((mb_strlen($this->container['sku']) > 255)) { + $invalidProperties[] = "invalid value for 'sku', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['sku']) < 1)) { + $invalidProperties[] = "invalid value for 'sku', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['sku'])) { + $invalidProperties[] = "invalid value for 'sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['bid'] === null) { + $invalidProperties[] = "'bid' can't be null"; + } + if (($this->container['bid'] > 9999)) { + $invalidProperties[] = "invalid value for 'bid', must be smaller than or equal to 9999."; + } + + if (($this->container['bid'] < 0)) { + $invalidProperties[] = "invalid value for 'bid', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets sku + * + * @return string + */ + public function getSku() + { + return $this->container['sku']; + } + + /** + * Sets sku + * + * @param string $sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setSku($sku) + { + if (is_null($sku)) { + throw new \InvalidArgumentException('non-nullable sku cannot be null'); + } + if ((mb_strlen($sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $sku when calling SkuBidItemDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $sku when calling SkuBidItemDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($sku)))) { + throw new \InvalidArgumentException("invalid value for \$sku when calling SkuBidItemDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['sku'] = $sku; + + return $this; + } + + /** + * Gets bid + * + * @return int + */ + public function getBid() + { + return $this->container['bid']; + } + + /** + * Sets bid + * + * @param int $bid Значение ставки. + * + * @return self + */ + public function setBid($bid) + { + if (is_null($bid)) { + throw new \InvalidArgumentException('non-nullable bid cannot be null'); + } + + if (($bid > 9999)) { + throw new \InvalidArgumentException('invalid value for $bid when calling SkuBidItemDTO., must be smaller than or equal to 9999.'); + } + if (($bid < 0)) { + throw new \InvalidArgumentException('invalid value for $bid when calling SkuBidItemDTO., must be bigger than or equal to 0.'); + } + + $this->container['bid'] = $bid; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SkuBidRecommendationItemDTO.php b/erp24/lib/yandex_market_api/Model/SkuBidRecommendationItemDTO.php new file mode 100644 index 00000000..8121f924 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SkuBidRecommendationItemDTO.php @@ -0,0 +1,570 @@ + + */ +class SkuBidRecommendationItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SkuBidRecommendationItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'sku' => 'string', + 'bid' => 'int', + 'bid_recommendations' => '\OpenAPI\Client\Model\BidRecommendationItemDTO[]', + 'price_recommendations' => '\OpenAPI\Client\Model\PriceRecommendationItemDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'sku' => null, + 'bid' => 'int32', + 'bid_recommendations' => null, + 'price_recommendations' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'sku' => false, + 'bid' => false, + 'bid_recommendations' => true, + 'price_recommendations' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'sku' => 'sku', + 'bid' => 'bid', + 'bid_recommendations' => 'bidRecommendations', + 'price_recommendations' => 'priceRecommendations' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'sku' => 'setSku', + 'bid' => 'setBid', + 'bid_recommendations' => 'setBidRecommendations', + 'price_recommendations' => 'setPriceRecommendations' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'sku' => 'getSku', + 'bid' => 'getBid', + 'bid_recommendations' => 'getBidRecommendations', + 'price_recommendations' => 'getPriceRecommendations' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('sku', $data ?? [], null); + $this->setIfExists('bid', $data ?? [], null); + $this->setIfExists('bid_recommendations', $data ?? [], null); + $this->setIfExists('price_recommendations', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['sku'] === null) { + $invalidProperties[] = "'sku' can't be null"; + } + if ((mb_strlen($this->container['sku']) > 255)) { + $invalidProperties[] = "invalid value for 'sku', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['sku']) < 1)) { + $invalidProperties[] = "invalid value for 'sku', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['sku'])) { + $invalidProperties[] = "invalid value for 'sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['bid'] === null) { + $invalidProperties[] = "'bid' can't be null"; + } + if (($this->container['bid'] > 9999)) { + $invalidProperties[] = "invalid value for 'bid', must be smaller than or equal to 9999."; + } + + if (($this->container['bid'] < 0)) { + $invalidProperties[] = "invalid value for 'bid', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets sku + * + * @return string + */ + public function getSku() + { + return $this->container['sku']; + } + + /** + * Sets sku + * + * @param string $sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setSku($sku) + { + if (is_null($sku)) { + throw new \InvalidArgumentException('non-nullable sku cannot be null'); + } + if ((mb_strlen($sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $sku when calling SkuBidRecommendationItemDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $sku when calling SkuBidRecommendationItemDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($sku)))) { + throw new \InvalidArgumentException("invalid value for \$sku when calling SkuBidRecommendationItemDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['sku'] = $sku; + + return $this; + } + + /** + * Gets bid + * + * @return int + */ + public function getBid() + { + return $this->container['bid']; + } + + /** + * Sets bid + * + * @param int $bid Значение ставки. + * + * @return self + */ + public function setBid($bid) + { + if (is_null($bid)) { + throw new \InvalidArgumentException('non-nullable bid cannot be null'); + } + + if (($bid > 9999)) { + throw new \InvalidArgumentException('invalid value for $bid when calling SkuBidRecommendationItemDTO., must be smaller than or equal to 9999.'); + } + if (($bid < 0)) { + throw new \InvalidArgumentException('invalid value for $bid when calling SkuBidRecommendationItemDTO., must be bigger than or equal to 0.'); + } + + $this->container['bid'] = $bid; + + return $this; + } + + /** + * Gets bid_recommendations + * + * @return \OpenAPI\Client\Model\BidRecommendationItemDTO[]|null + */ + public function getBidRecommendations() + { + return $this->container['bid_recommendations']; + } + + /** + * Sets bid_recommendations + * + * @param \OpenAPI\Client\Model\BidRecommendationItemDTO[]|null $bid_recommendations Список рекомендованных ставок с соответствующими долями показов. Чем больше ставка, тем большую долю показов она помогает получить. + * + * @return self + */ + public function setBidRecommendations($bid_recommendations) + { + if (is_null($bid_recommendations)) { + array_push($this->openAPINullablesSetToNull, 'bid_recommendations'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('bid_recommendations', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['bid_recommendations'] = $bid_recommendations; + + return $this; + } + + /** + * Gets price_recommendations + * + * @return \OpenAPI\Client\Model\PriceRecommendationItemDTO[]|null + */ + public function getPriceRecommendations() + { + return $this->container['price_recommendations']; + } + + /** + * Sets price_recommendations + * + * @param \OpenAPI\Client\Model\PriceRecommendationItemDTO[]|null $price_recommendations Рекомендованные цены. + * + * @return self + */ + public function setPriceRecommendations($price_recommendations) + { + if (is_null($price_recommendations)) { + array_push($this->openAPINullablesSetToNull, 'price_recommendations'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('price_recommendations', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['price_recommendations'] = $price_recommendations; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SortOrderType.php b/erp24/lib/yandex_market_api/Model/SortOrderType.php new file mode 100644 index 00000000..4de6b0e0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SortOrderType.php @@ -0,0 +1,63 @@ + + */ +class SuggestOfferPriceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SuggestOfferPriceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'market_sku' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'market_sku' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'market_sku' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'market_sku' => 'marketSku' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'market_sku' => 'setMarketSku' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'market_sku' => 'getMarketSku' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('market_sku', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling SuggestOfferPriceDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling SuggestOfferPriceDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling SuggestOfferPriceDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling SuggestOfferPriceDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SuggestPricesRequest.php b/erp24/lib/yandex_market_api/Model/SuggestPricesRequest.php new file mode 100644 index 00000000..06acf7d7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SuggestPricesRequest.php @@ -0,0 +1,421 @@ + + */ +class SuggestPricesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SuggestPricesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\SuggestOfferPriceDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + if ((count($this->container['offers']) > 1000)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be less than or equal to 1000."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\SuggestOfferPriceDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\SuggestOfferPriceDTO[] $offers Список товаров. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + + if ((count($offers) > 1000)) { + throw new \InvalidArgumentException('invalid value for $offers when calling SuggestPricesRequest., number of items must be less than or equal to 1000.'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SuggestPricesResponse.php b/erp24/lib/yandex_market_api/Model/SuggestPricesResponse.php new file mode 100644 index 00000000..d4d9039c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SuggestPricesResponse.php @@ -0,0 +1,444 @@ + + */ +class SuggestPricesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SuggestPricesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\SuggestPricesResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\SuggestPricesResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\SuggestPricesResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SuggestPricesResultDTO.php b/erp24/lib/yandex_market_api/Model/SuggestPricesResultDTO.php new file mode 100644 index 00000000..69d57c55 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SuggestPricesResultDTO.php @@ -0,0 +1,413 @@ + + */ +class SuggestPricesResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SuggestPricesResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\PriceSuggestOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\PriceSuggestOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\PriceSuggestOfferDTO[] $offers Список товаров с ценами для продвижения. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SuggestedOfferDTO.php b/erp24/lib/yandex_market_api/Model/SuggestedOfferDTO.php new file mode 100644 index 00000000..6babc760 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SuggestedOfferDTO.php @@ -0,0 +1,693 @@ + + */ +class SuggestedOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SuggestedOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'name' => 'string', + 'category' => 'string', + 'vendor' => 'string', + 'barcodes' => 'string[]', + 'description' => 'string', + 'vendor_code' => 'string', + 'basic_price' => '\OpenAPI\Client\Model\BasePriceDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'name' => null, + 'category' => null, + 'vendor' => null, + 'barcodes' => null, + 'description' => null, + 'vendor_code' => null, + 'basic_price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'name' => false, + 'category' => false, + 'vendor' => false, + 'barcodes' => true, + 'description' => false, + 'vendor_code' => false, + 'basic_price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'name' => 'name', + 'category' => 'category', + 'vendor' => 'vendor', + 'barcodes' => 'barcodes', + 'description' => 'description', + 'vendor_code' => 'vendorCode', + 'basic_price' => 'basicPrice' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'name' => 'setName', + 'category' => 'setCategory', + 'vendor' => 'setVendor', + 'barcodes' => 'setBarcodes', + 'description' => 'setDescription', + 'vendor_code' => 'setVendorCode', + 'basic_price' => 'setBasicPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'name' => 'getName', + 'category' => 'getCategory', + 'vendor' => 'getVendor', + 'barcodes' => 'getBarcodes', + 'description' => 'getDescription', + 'vendor_code' => 'getVendorCode', + 'basic_price' => 'getBasicPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); + $this->setIfExists('vendor', $data ?? [], null); + $this->setIfExists('barcodes', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('vendor_code', $data ?? [], null); + $this->setIfExists('basic_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['offer_id']) && (mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['offer_id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 256)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 6000)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 6000."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string|null + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string|null $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling SuggestedOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling SuggestedOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling SuggestedOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Составляйте название по схеме: тип + бренд или производитель + модель + особенности, если есть (например, цвет, размер или вес) и количество в упаковке. Не включайте в название условия продажи (например, «скидка», «бесплатная доставка» и т. д.), эмоциональные характеристики («хит», «супер» и т. д.). Не пишите слова большими буквами — кроме устоявшихся названий брендов и моделей. Оптимальная длина — 50–60 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/title.html) + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + if ((mb_strlen($name) > 256)) { + throw new \InvalidArgumentException('invalid length for $name when calling SuggestedOfferDTO., must be smaller than or equal to 256.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category Категория товара в вашем магазине. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. Указывайте конкретные категории — например, набор ножей лучше отнести к категории **Столовые приборы**, а не просто **Посуда**. Выбирайте категории, которые описывают товар, а не абстрактный признак — например, **Духи**, а не **Подарки**. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. + * + * @return self + */ + public function setCategory($category) + { + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets vendor + * + * @return string|null + */ + public function getVendor() + { + return $this->container['vendor']; + } + + /** + * Sets vendor + * + * @param string|null $vendor Название бренда или производителя. Должно быть записано так, как его пишет сам бренд. + * + * @return self + */ + public function setVendor($vendor) + { + if (is_null($vendor)) { + throw new \InvalidArgumentException('non-nullable vendor cannot be null'); + } + $this->container['vendor'] = $vendor; + + return $this; + } + + /** + * Gets barcodes + * + * @return string[]|null + */ + public function getBarcodes() + { + return $this->container['barcodes']; + } + + /** + * Sets barcodes + * + * @param string[]|null $barcodes Указывайте в виде последовательности цифр. Подойдут коды EAN-13, EAN-8, UPC-A, UPC-E или Code 128. Для книг указывайте ISBN. Для товаров [определенных категорий и торговых марок](https://yastatic.net/s3/doc-binary/src/support/market/ru/yandex-market-list-for-gtin.xlsx) штрихкод должен быть действительным кодом GTIN. Обратите внимание: внутренние штрихкоды, начинающиеся на 2 или 02, и коды формата Code 128 не являются GTIN. [Что такое GTIN](*gtin) + * + * @return self + */ + public function setBarcodes($barcodes) + { + if (is_null($barcodes)) { + array_push($this->openAPINullablesSetToNull, 'barcodes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('barcodes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['barcodes'] = $barcodes; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Подробное описание товара: например, его преимущества и особенности. Не давайте в описании инструкций по установке и сборке. Не используйте слова «скидка», «распродажа», «дешевый», «подарок» (кроме подарочных категорий), «бесплатно», «акция», «специальная цена», «новинка», «new», «аналог», «заказ», «хит». Не указывайте никакой контактной информации и не давайте ссылок. Можно использовать теги: * \\, \\

                                          , \\

                                          и так далее — для заголовков; * \\
                                          и \\

                                          — для переноса строки; * \\

                                            — для нумерованного списка; * \\
                                              — для маркированного списка; * \\
                                            • — для создания элементов списка (должен находиться внутри \\
                                                или \\
                                                  ); * \\
                                                  — поддерживается, но не влияет на отображение текста. Оптимальная длина — 400–600 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/description.html) + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + if ((mb_strlen($description) > 6000)) { + throw new \InvalidArgumentException('invalid length for $description when calling SuggestedOfferDTO., must be smaller than or equal to 6000.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets vendor_code + * + * @return string|null + */ + public function getVendorCode() + { + return $this->container['vendor_code']; + } + + /** + * Sets vendor_code + * + * @param string|null $vendor_code Артикул товара от производителя. + * + * @return self + */ + public function setVendorCode($vendor_code) + { + if (is_null($vendor_code)) { + throw new \InvalidArgumentException('non-nullable vendor_code cannot be null'); + } + $this->container['vendor_code'] = $vendor_code; + + return $this; + } + + /** + * Gets basic_price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getBasicPrice() + { + return $this->container['basic_price']; + } + + /** + * Sets basic_price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $basic_price basic_price + * + * @return self + */ + public function setBasicPrice($basic_price) + { + if (is_null($basic_price)) { + throw new \InvalidArgumentException('non-nullable basic_price cannot be null'); + } + $this->container['basic_price'] = $basic_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/SuggestedOfferMappingDTO.php b/erp24/lib/yandex_market_api/Model/SuggestedOfferMappingDTO.php new file mode 100644 index 00000000..c76205d3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/SuggestedOfferMappingDTO.php @@ -0,0 +1,444 @@ + + */ +class SuggestedOfferMappingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'SuggestedOfferMappingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer' => '\OpenAPI\Client\Model\SuggestedOfferDTO', + 'mapping' => '\OpenAPI\Client\Model\GetMappingDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer' => null, + 'mapping' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer' => false, + 'mapping' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer' => 'offer', + 'mapping' => 'mapping' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer' => 'setOffer', + 'mapping' => 'setMapping' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer' => 'getOffer', + 'mapping' => 'getMapping' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer', $data ?? [], null); + $this->setIfExists('mapping', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer + * + * @return \OpenAPI\Client\Model\SuggestedOfferDTO|null + */ + public function getOffer() + { + return $this->container['offer']; + } + + /** + * Sets offer + * + * @param \OpenAPI\Client\Model\SuggestedOfferDTO|null $offer offer + * + * @return self + */ + public function setOffer($offer) + { + if (is_null($offer)) { + throw new \InvalidArgumentException('non-nullable offer cannot be null'); + } + $this->container['offer'] = $offer; + + return $this; + } + + /** + * Gets mapping + * + * @return \OpenAPI\Client\Model\GetMappingDTO|null + */ + public function getMapping() + { + return $this->container['mapping']; + } + + /** + * Sets mapping + * + * @param \OpenAPI\Client\Model\GetMappingDTO|null $mapping mapping + * + * @return self + */ + public function setMapping($mapping) + { + if (is_null($mapping)) { + throw new \InvalidArgumentException('non-nullable mapping cannot be null'); + } + $this->container['mapping'] = $mapping; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/TariffDTO.php b/erp24/lib/yandex_market_api/Model/TariffDTO.php new file mode 100644 index 00000000..f21228b3 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/TariffDTO.php @@ -0,0 +1,523 @@ + + */ +class TariffDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TariffDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\TariffType', + 'percent' => 'float', + 'amount' => 'float', + 'parameters' => '\OpenAPI\Client\Model\TariffParameterDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'percent' => null, + 'amount' => null, + 'parameters' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'percent' => false, + 'amount' => false, + 'parameters' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'percent' => 'percent', + 'amount' => 'amount', + 'parameters' => 'parameters' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'percent' => 'setPercent', + 'amount' => 'setAmount', + 'parameters' => 'setParameters' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'percent' => 'getPercent', + 'amount' => 'getAmount', + 'parameters' => 'getParameters' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('percent', $data ?? [], null); + $this->setIfExists('amount', $data ?? [], null); + $this->setIfExists('parameters', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['amount'] === null) { + $invalidProperties[] = "'amount' can't be null"; + } + if ($this->container['parameters'] === null) { + $invalidProperties[] = "'parameters' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\TariffType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\TariffType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets percent + * + * @return float|null + * @deprecated + */ + public function getPercent() + { + return $this->container['percent']; + } + + /** + * Sets percent + * + * @param float|null $percent {% note warning \"\" %} Этот параметр устарел. Не используйте его. {% endnote %} Значение тарифа в процентах. + * + * @return self + * @deprecated + */ + public function setPercent($percent) + { + if (is_null($percent)) { + throw new \InvalidArgumentException('non-nullable percent cannot be null'); + } + $this->container['percent'] = $percent; + + return $this; + } + + /** + * Gets amount + * + * @return float + */ + public function getAmount() + { + return $this->container['amount']; + } + + /** + * Sets amount + * + * @param float $amount Значение тарифа в рублях. + * + * @return self + */ + public function setAmount($amount) + { + if (is_null($amount)) { + throw new \InvalidArgumentException('non-nullable amount cannot be null'); + } + $this->container['amount'] = $amount; + + return $this; + } + + /** + * Gets parameters + * + * @return \OpenAPI\Client\Model\TariffParameterDTO[] + */ + public function getParameters() + { + return $this->container['parameters']; + } + + /** + * Sets parameters + * + * @param \OpenAPI\Client\Model\TariffParameterDTO[] $parameters Параметры расчета тарифа. + * + * @return self + */ + public function setParameters($parameters) + { + if (is_null($parameters)) { + throw new \InvalidArgumentException('non-nullable parameters cannot be null'); + } + $this->container['parameters'] = $parameters; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/TariffParameterDTO.php b/erp24/lib/yandex_market_api/Model/TariffParameterDTO.php new file mode 100644 index 00000000..bbd82182 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/TariffParameterDTO.php @@ -0,0 +1,450 @@ + + */ +class TariffParameterDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TariffParameterDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'value' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'value' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'value' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'value' => 'value' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'value' => 'setValue' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'value' => 'getValue' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('value', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название параметра. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets value + * + * @return string + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string $value Значение параметра. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + $this->container['value'] = $value; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/TariffType.php b/erp24/lib/yandex_market_api/Model/TariffType.php new file mode 100644 index 00000000..a0a4da18 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/TariffType.php @@ -0,0 +1,135 @@ + + */ +class TimePeriodDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TimePeriodDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'time_period' => 'int', + 'time_unit' => '\OpenAPI\Client\Model\TimeUnitType', + 'comment' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'time_period' => null, + 'time_unit' => null, + 'comment' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'time_period' => false, + 'time_unit' => false, + 'comment' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'time_period' => 'timePeriod', + 'time_unit' => 'timeUnit', + 'comment' => 'comment' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'time_period' => 'setTimePeriod', + 'time_unit' => 'setTimeUnit', + 'comment' => 'setComment' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'time_period' => 'getTimePeriod', + 'time_unit' => 'getTimeUnit', + 'comment' => 'getComment' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('time_period', $data ?? [], null); + $this->setIfExists('time_unit', $data ?? [], null); + $this->setIfExists('comment', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['time_period'] === null) { + $invalidProperties[] = "'time_period' can't be null"; + } + if ($this->container['time_unit'] === null) { + $invalidProperties[] = "'time_unit' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets time_period + * + * @return int + */ + public function getTimePeriod() + { + return $this->container['time_period']; + } + + /** + * Sets time_period + * + * @param int $time_period Продолжительность в указанных единицах. + * + * @return self + */ + public function setTimePeriod($time_period) + { + if (is_null($time_period)) { + throw new \InvalidArgumentException('non-nullable time_period cannot be null'); + } + $this->container['time_period'] = $time_period; + + return $this; + } + + /** + * Gets time_unit + * + * @return \OpenAPI\Client\Model\TimeUnitType + */ + public function getTimeUnit() + { + return $this->container['time_unit']; + } + + /** + * Sets time_unit + * + * @param \OpenAPI\Client\Model\TimeUnitType $time_unit time_unit + * + * @return self + */ + public function setTimeUnit($time_unit) + { + if (is_null($time_unit)) { + throw new \InvalidArgumentException('non-nullable time_unit cannot be null'); + } + $this->container['time_unit'] = $time_unit; + + return $this; + } + + /** + * Gets comment + * + * @return string|null + */ + public function getComment() + { + return $this->container['comment']; + } + + /** + * Sets comment + * + * @param string|null $comment Комментарий. + * + * @return self + */ + public function setComment($comment) + { + if (is_null($comment)) { + throw new \InvalidArgumentException('non-nullable comment cannot be null'); + } + $this->container['comment'] = $comment; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/TimeUnitType.php b/erp24/lib/yandex_market_api/Model/TimeUnitType.php new file mode 100644 index 00000000..c6135f40 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/TimeUnitType.php @@ -0,0 +1,72 @@ + + */ +class TrackDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TrackDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'track_code' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'track_code' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'track_code' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'track_code' => 'trackCode' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'track_code' => 'setTrackCode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'track_code' => 'getTrackCode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('track_code', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets track_code + * + * @return string|null + */ + public function getTrackCode() + { + return $this->container['track_code']; + } + + /** + * Sets track_code + * + * @param string|null $track_code Трек-код почтового отправления. + * + * @return self + */ + public function setTrackCode($track_code) + { + if (is_null($track_code)) { + throw new \InvalidArgumentException('non-nullable track_code cannot be null'); + } + $this->container['track_code'] = $track_code; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/TransferOrdersFromShipmentRequest.php b/erp24/lib/yandex_market_api/Model/TransferOrdersFromShipmentRequest.php new file mode 100644 index 00000000..9f801199 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/TransferOrdersFromShipmentRequest.php @@ -0,0 +1,428 @@ + + */ +class TransferOrdersFromShipmentRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TransferOrdersFromShipmentRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order_ids' => 'int[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order_ids' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order_ids' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order_ids' => 'orderIds' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order_ids' => 'setOrderIds' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order_ids' => 'getOrderIds' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order_ids', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['order_ids'] === null) { + $invalidProperties[] = "'order_ids' can't be null"; + } + if ((count($this->container['order_ids']) > 500)) { + $invalidProperties[] = "invalid value for 'order_ids', number of items must be less than or equal to 500."; + } + + if ((count($this->container['order_ids']) < 1)) { + $invalidProperties[] = "invalid value for 'order_ids', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order_ids + * + * @return int[] + */ + public function getOrderIds() + { + return $this->container['order_ids']; + } + + /** + * Sets order_ids + * + * @param int[] $order_ids Список заказов, которые вы не успеваете подготовить. + * + * @return self + */ + public function setOrderIds($order_ids) + { + if (is_null($order_ids)) { + throw new \InvalidArgumentException('non-nullable order_ids cannot be null'); + } + + if ((count($order_ids) > 500)) { + throw new \InvalidArgumentException('invalid value for $order_ids when calling TransferOrdersFromShipmentRequest., number of items must be less than or equal to 500.'); + } + if ((count($order_ids) < 1)) { + throw new \InvalidArgumentException('invalid length for $order_ids when calling TransferOrdersFromShipmentRequest., number of items must be greater than or equal to 1.'); + } + $this->container['order_ids'] = $order_ids; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/TurnoverDTO.php b/erp24/lib/yandex_market_api/Model/TurnoverDTO.php new file mode 100644 index 00000000..538f6333 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/TurnoverDTO.php @@ -0,0 +1,447 @@ + + */ +class TurnoverDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'TurnoverDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'turnover' => '\OpenAPI\Client\Model\TurnoverType', + 'turnover_days' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'turnover' => null, + 'turnover_days' => 'double' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'turnover' => false, + 'turnover_days' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'turnover' => 'turnover', + 'turnover_days' => 'turnoverDays' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'turnover' => 'setTurnover', + 'turnover_days' => 'setTurnoverDays' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'turnover' => 'getTurnover', + 'turnover_days' => 'getTurnoverDays' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('turnover', $data ?? [], null); + $this->setIfExists('turnover_days', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['turnover'] === null) { + $invalidProperties[] = "'turnover' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets turnover + * + * @return \OpenAPI\Client\Model\TurnoverType + */ + public function getTurnover() + { + return $this->container['turnover']; + } + + /** + * Sets turnover + * + * @param \OpenAPI\Client\Model\TurnoverType $turnover turnover + * + * @return self + */ + public function setTurnover($turnover) + { + if (is_null($turnover)) { + throw new \InvalidArgumentException('non-nullable turnover cannot be null'); + } + $this->container['turnover'] = $turnover; + + return $this; + } + + /** + * Gets turnover_days + * + * @return float|null + */ + public function getTurnoverDays() + { + return $this->container['turnover_days']; + } + + /** + * Sets turnover_days + * + * @param float|null $turnover_days Значение в днях. [Что это за число?](https://yandex.ru/support/marketplace/analytics/turnover.html) + * + * @return self + */ + public function setTurnoverDays($turnover_days) + { + if (is_null($turnover_days)) { + throw new \InvalidArgumentException('non-nullable turnover_days cannot be null'); + } + $this->container['turnover_days'] = $turnover_days; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/TurnoverType.php b/erp24/lib/yandex_market_api/Model/TurnoverType.php new file mode 100644 index 00000000..2ac6897d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/TurnoverType.php @@ -0,0 +1,75 @@ + + */ +class UnitDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UnitDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'full_name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'full_name' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'full_name' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'full_name' => 'fullName' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'full_name' => 'setFullName' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'full_name' => 'getFullName' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('full_name', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['full_name'] === null) { + $invalidProperties[] = "'full_name' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор единицы измерения. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Сокращенное название единицы измерения. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets full_name + * + * @return string + */ + public function getFullName() + { + return $this->container['full_name']; + } + + /** + * Sets full_name + * + * @param string $full_name Полное название единицы измерения. + * + * @return self + */ + public function setFullName($full_name) + { + if (is_null($full_name)) { + throw new \InvalidArgumentException('non-nullable full_name cannot be null'); + } + $this->container['full_name'] = $full_name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateBusinessOfferPriceDTO.php b/erp24/lib/yandex_market_api/Model/UpdateBusinessOfferPriceDTO.php new file mode 100644 index 00000000..0e208b5c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateBusinessOfferPriceDTO.php @@ -0,0 +1,472 @@ + + */ +class UpdateBusinessOfferPriceDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateBusinessOfferPriceDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'price' => '\OpenAPI\Client\Model\UpdatePriceWithDiscountDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'price' => 'price' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'price' => 'setPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'price' => 'getPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['price'] === null) { + $invalidProperties[] = "'price' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateBusinessOfferPriceDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateBusinessOfferPriceDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling UpdateBusinessOfferPriceDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets price + * + * @return \OpenAPI\Client\Model\UpdatePriceWithDiscountDTO + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param \OpenAPI\Client\Model\UpdatePriceWithDiscountDTO $price price + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + $this->container['price'] = $price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateBusinessPricesRequest.php b/erp24/lib/yandex_market_api/Model/UpdateBusinessPricesRequest.php new file mode 100644 index 00000000..0060ec42 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateBusinessPricesRequest.php @@ -0,0 +1,428 @@ + + */ +class UpdateBusinessPricesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateBusinessPricesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\UpdateBusinessOfferPriceDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + if ((count($this->container['offers']) > 500)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be less than or equal to 500."; + } + + if ((count($this->container['offers']) < 1)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\UpdateBusinessOfferPriceDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\UpdateBusinessOfferPriceDTO[] $offers Список товаров с ценами. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + + if ((count($offers) > 500)) { + throw new \InvalidArgumentException('invalid value for $offers when calling UpdateBusinessPricesRequest., number of items must be less than or equal to 500.'); + } + if ((count($offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $offers when calling UpdateBusinessPricesRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateCampaignOfferDTO.php b/erp24/lib/yandex_market_api/Model/UpdateCampaignOfferDTO.php new file mode 100644 index 00000000..281150f0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateCampaignOfferDTO.php @@ -0,0 +1,537 @@ + + */ +class UpdateCampaignOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateCampaignOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'quantum' => '\OpenAPI\Client\Model\QuantumDTO', + 'available' => 'bool', + 'vat' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'quantum' => null, + 'available' => null, + 'vat' => 'int32' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'quantum' => false, + 'available' => false, + 'vat' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'quantum' => 'quantum', + 'available' => 'available', + 'vat' => 'vat' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'quantum' => 'setQuantum', + 'available' => 'setAvailable', + 'vat' => 'setVat' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'quantum' => 'getQuantum', + 'available' => 'getAvailable', + 'vat' => 'getVat' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('quantum', $data ?? [], null); + $this->setIfExists('available', $data ?? [], null); + $this->setIfExists('vat', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateCampaignOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateCampaignOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling UpdateCampaignOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets quantum + * + * @return \OpenAPI\Client\Model\QuantumDTO|null + */ + public function getQuantum() + { + return $this->container['quantum']; + } + + /** + * Sets quantum + * + * @param \OpenAPI\Client\Model\QuantumDTO|null $quantum quantum + * + * @return self + */ + public function setQuantum($quantum) + { + if (is_null($quantum)) { + throw new \InvalidArgumentException('non-nullable quantum cannot be null'); + } + $this->container['quantum'] = $quantum; + + return $this; + } + + /** + * Gets available + * + * @return bool|null + */ + public function getAvailable() + { + return $this->container['available']; + } + + /** + * Sets available + * + * @param bool|null $available Есть ли товар в продаже. + * + * @return self + */ + public function setAvailable($available) + { + if (is_null($available)) { + throw new \InvalidArgumentException('non-nullable available cannot be null'); + } + $this->container['available'] = $available; + + return $this; + } + + /** + * Gets vat + * + * @return int|null + */ + public function getVat() + { + return $this->container['vat']; + } + + /** + * Sets vat + * + * @param int|null $vat Ставка НДС, применяемая для товара. Задается цифрой: * `2` — 10%. * `5` — 0%. * `6` — не облагается НДС. * `7` — 20%. Если параметр не указан, используется ставка НДС, установленная в кабинете продавца на Маркете. + * + * @return self + */ + public function setVat($vat) + { + if (is_null($vat)) { + throw new \InvalidArgumentException('non-nullable vat cannot be null'); + } + $this->container['vat'] = $vat; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateCampaignOffersRequest.php b/erp24/lib/yandex_market_api/Model/UpdateCampaignOffersRequest.php new file mode 100644 index 00000000..8ffed9d8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateCampaignOffersRequest.php @@ -0,0 +1,428 @@ + + */ +class UpdateCampaignOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateCampaignOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\UpdateCampaignOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + if ((count($this->container['offers']) > 500)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be less than or equal to 500."; + } + + if ((count($this->container['offers']) < 1)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\UpdateCampaignOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\UpdateCampaignOfferDTO[] $offers Параметры размещения товаров в заданном магазине. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + + if ((count($offers) > 500)) { + throw new \InvalidArgumentException('invalid value for $offers when calling UpdateCampaignOffersRequest., number of items must be less than or equal to 500.'); + } + if ((count($offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $offers when calling UpdateCampaignOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentDTO.php b/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentDTO.php new file mode 100644 index 00000000..1cceeea6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentDTO.php @@ -0,0 +1,496 @@ + + */ +class UpdateGoodsFeedbackCommentDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateGoodsFeedbackCommentDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'parent_id' => 'int', + 'text' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'parent_id' => 'int64', + 'text' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'parent_id' => false, + 'text' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'parent_id' => 'parentId', + 'text' => 'text' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'parent_id' => 'setParentId', + 'text' => 'setText' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'parent_id' => 'getParentId', + 'text' => 'getText' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('parent_id', $data ?? [], null); + $this->setIfExists('text', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['text'] === null) { + $invalidProperties[] = "'text' can't be null"; + } + if ((mb_strlen($this->container['text']) > 4096)) { + $invalidProperties[] = "invalid value for 'text', the character length must be smaller than or equal to 4096."; + } + + if ((mb_strlen($this->container['text']) < 1)) { + $invalidProperties[] = "invalid value for 'text', the character length must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор комментария к отзыву. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets parent_id + * + * @return int|null + */ + public function getParentId() + { + return $this->container['parent_id']; + } + + /** + * Sets parent_id + * + * @param int|null $parent_id Идентификатор комментария к отзыву. + * + * @return self + */ + public function setParentId($parent_id) + { + if (is_null($parent_id)) { + throw new \InvalidArgumentException('non-nullable parent_id cannot be null'); + } + $this->container['parent_id'] = $parent_id; + + return $this; + } + + /** + * Gets text + * + * @return string + */ + public function getText() + { + return $this->container['text']; + } + + /** + * Sets text + * + * @param string $text Текст комментария. + * + * @return self + */ + public function setText($text) + { + if (is_null($text)) { + throw new \InvalidArgumentException('non-nullable text cannot be null'); + } + if ((mb_strlen($text) > 4096)) { + throw new \InvalidArgumentException('invalid length for $text when calling UpdateGoodsFeedbackCommentDTO., must be smaller than or equal to 4096.'); + } + if ((mb_strlen($text) < 1)) { + throw new \InvalidArgumentException('invalid length for $text when calling UpdateGoodsFeedbackCommentDTO., must be bigger than or equal to 1.'); + } + + $this->container['text'] = $text; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentRequest.php b/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentRequest.php new file mode 100644 index 00000000..3f86ea49 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentRequest.php @@ -0,0 +1,450 @@ + + */ +class UpdateGoodsFeedbackCommentRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateGoodsFeedbackCommentRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'feedback_id' => 'int', + 'comment' => '\OpenAPI\Client\Model\UpdateGoodsFeedbackCommentDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'feedback_id' => 'int64', + 'comment' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'feedback_id' => false, + 'comment' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'feedback_id' => 'feedbackId', + 'comment' => 'comment' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'feedback_id' => 'setFeedbackId', + 'comment' => 'setComment' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'feedback_id' => 'getFeedbackId', + 'comment' => 'getComment' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('feedback_id', $data ?? [], null); + $this->setIfExists('comment', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['feedback_id'] === null) { + $invalidProperties[] = "'feedback_id' can't be null"; + } + if ($this->container['comment'] === null) { + $invalidProperties[] = "'comment' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets feedback_id + * + * @return int + */ + public function getFeedbackId() + { + return $this->container['feedback_id']; + } + + /** + * Sets feedback_id + * + * @param int $feedback_id Идентификатор отзыва. + * + * @return self + */ + public function setFeedbackId($feedback_id) + { + if (is_null($feedback_id)) { + throw new \InvalidArgumentException('non-nullable feedback_id cannot be null'); + } + $this->container['feedback_id'] = $feedback_id; + + return $this; + } + + /** + * Gets comment + * + * @return \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentDTO + */ + public function getComment() + { + return $this->container['comment']; + } + + /** + * Sets comment + * + * @param \OpenAPI\Client\Model\UpdateGoodsFeedbackCommentDTO $comment comment + * + * @return self + */ + public function setComment($comment) + { + if (is_null($comment)) { + throw new \InvalidArgumentException('non-nullable comment cannot be null'); + } + $this->container['comment'] = $comment; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentResponse.php b/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentResponse.php new file mode 100644 index 00000000..95f8739f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateGoodsFeedbackCommentResponse.php @@ -0,0 +1,443 @@ + + */ +class UpdateGoodsFeedbackCommentResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateGoodsFeedbackCommentResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\GoodsFeedbackCommentDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\GoodsFeedbackCommentDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\GoodsFeedbackCommentDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateMappingDTO.php b/erp24/lib/yandex_market_api/Model/UpdateMappingDTO.php new file mode 100644 index 00000000..37836488 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateMappingDTO.php @@ -0,0 +1,419 @@ + + */ +class UpdateMappingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateMappingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'market_sku' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'market_sku' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'market_sku' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'market_sku' => 'marketSku' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'market_sku' => 'setMarketSku' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'market_sku' => 'getMarketSku' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('market_sku', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['market_sku']) && ($this->container['market_sku'] < 1)) { + $invalidProperties[] = "invalid value for 'market_sku', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets market_sku + * + * @return int|null + */ + public function getMarketSku() + { + return $this->container['market_sku']; + } + + /** + * Sets market_sku + * + * @param int|null $market_sku SKU на Маркете. + * + * @return self + */ + public function setMarketSku($market_sku) + { + if (is_null($market_sku)) { + throw new \InvalidArgumentException('non-nullable market_sku cannot be null'); + } + + if (($market_sku < 1)) { + throw new \InvalidArgumentException('invalid value for $market_sku when calling UpdateMappingDTO., must be bigger than or equal to 1.'); + } + + $this->container['market_sku'] = $market_sku; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateMappingsOfferDTO.php b/erp24/lib/yandex_market_api/Model/UpdateMappingsOfferDTO.php new file mode 100644 index 00000000..e913c0ea --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateMappingsOfferDTO.php @@ -0,0 +1,1498 @@ + + */ +class UpdateMappingsOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateMappingsOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'shop_sku' => 'string', + 'category' => 'string', + 'vendor' => 'string', + 'vendor_code' => 'string', + 'description' => 'string', + 'id' => 'string', + 'feed_id' => 'int', + 'barcodes' => 'string[]', + 'urls' => 'string[]', + 'pictures' => 'string[]', + 'manufacturer' => 'string', + 'manufacturer_countries' => 'string[]', + 'min_shipment' => 'int', + 'transport_unit_size' => 'int', + 'quantum_of_supply' => 'int', + 'delivery_duration_days' => 'int', + 'box_count' => 'int', + 'customs_commodity_codes' => 'string[]', + 'weight_dimensions' => '\OpenAPI\Client\Model\OfferWeightDimensionsDTO', + 'supply_schedule_days' => '\OpenAPI\Client\Model\DayOfWeekType[]', + 'shelf_life_days' => 'int', + 'life_time_days' => 'int', + 'guarantee_period_days' => 'int', + 'processing_state' => '\OpenAPI\Client\Model\OfferProcessingStateDTO', + 'availability' => '\OpenAPI\Client\Model\OfferAvailabilityStatusType', + 'shelf_life' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'life_time' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'guarantee_period' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'certificate' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'shop_sku' => null, + 'category' => null, + 'vendor' => null, + 'vendor_code' => null, + 'description' => null, + 'id' => null, + 'feed_id' => 'int64', + 'barcodes' => null, + 'urls' => null, + 'pictures' => null, + 'manufacturer' => null, + 'manufacturer_countries' => null, + 'min_shipment' => 'int32', + 'transport_unit_size' => 'int32', + 'quantum_of_supply' => 'int32', + 'delivery_duration_days' => 'int32', + 'box_count' => 'int32', + 'customs_commodity_codes' => null, + 'weight_dimensions' => null, + 'supply_schedule_days' => null, + 'shelf_life_days' => 'int32', + 'life_time_days' => 'int32', + 'guarantee_period_days' => 'int32', + 'processing_state' => null, + 'availability' => null, + 'shelf_life' => null, + 'life_time' => null, + 'guarantee_period' => null, + 'certificate' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'shop_sku' => false, + 'category' => false, + 'vendor' => false, + 'vendor_code' => false, + 'description' => false, + 'id' => false, + 'feed_id' => false, + 'barcodes' => true, + 'urls' => true, + 'pictures' => true, + 'manufacturer' => false, + 'manufacturer_countries' => true, + 'min_shipment' => false, + 'transport_unit_size' => false, + 'quantum_of_supply' => false, + 'delivery_duration_days' => false, + 'box_count' => false, + 'customs_commodity_codes' => true, + 'weight_dimensions' => false, + 'supply_schedule_days' => true, + 'shelf_life_days' => false, + 'life_time_days' => false, + 'guarantee_period_days' => false, + 'processing_state' => false, + 'availability' => false, + 'shelf_life' => false, + 'life_time' => false, + 'guarantee_period' => false, + 'certificate' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'shop_sku' => 'shopSku', + 'category' => 'category', + 'vendor' => 'vendor', + 'vendor_code' => 'vendorCode', + 'description' => 'description', + 'id' => 'id', + 'feed_id' => 'feedId', + 'barcodes' => 'barcodes', + 'urls' => 'urls', + 'pictures' => 'pictures', + 'manufacturer' => 'manufacturer', + 'manufacturer_countries' => 'manufacturerCountries', + 'min_shipment' => 'minShipment', + 'transport_unit_size' => 'transportUnitSize', + 'quantum_of_supply' => 'quantumOfSupply', + 'delivery_duration_days' => 'deliveryDurationDays', + 'box_count' => 'boxCount', + 'customs_commodity_codes' => 'customsCommodityCodes', + 'weight_dimensions' => 'weightDimensions', + 'supply_schedule_days' => 'supplyScheduleDays', + 'shelf_life_days' => 'shelfLifeDays', + 'life_time_days' => 'lifeTimeDays', + 'guarantee_period_days' => 'guaranteePeriodDays', + 'processing_state' => 'processingState', + 'availability' => 'availability', + 'shelf_life' => 'shelfLife', + 'life_time' => 'lifeTime', + 'guarantee_period' => 'guaranteePeriod', + 'certificate' => 'certificate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'shop_sku' => 'setShopSku', + 'category' => 'setCategory', + 'vendor' => 'setVendor', + 'vendor_code' => 'setVendorCode', + 'description' => 'setDescription', + 'id' => 'setId', + 'feed_id' => 'setFeedId', + 'barcodes' => 'setBarcodes', + 'urls' => 'setUrls', + 'pictures' => 'setPictures', + 'manufacturer' => 'setManufacturer', + 'manufacturer_countries' => 'setManufacturerCountries', + 'min_shipment' => 'setMinShipment', + 'transport_unit_size' => 'setTransportUnitSize', + 'quantum_of_supply' => 'setQuantumOfSupply', + 'delivery_duration_days' => 'setDeliveryDurationDays', + 'box_count' => 'setBoxCount', + 'customs_commodity_codes' => 'setCustomsCommodityCodes', + 'weight_dimensions' => 'setWeightDimensions', + 'supply_schedule_days' => 'setSupplyScheduleDays', + 'shelf_life_days' => 'setShelfLifeDays', + 'life_time_days' => 'setLifeTimeDays', + 'guarantee_period_days' => 'setGuaranteePeriodDays', + 'processing_state' => 'setProcessingState', + 'availability' => 'setAvailability', + 'shelf_life' => 'setShelfLife', + 'life_time' => 'setLifeTime', + 'guarantee_period' => 'setGuaranteePeriod', + 'certificate' => 'setCertificate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'shop_sku' => 'getShopSku', + 'category' => 'getCategory', + 'vendor' => 'getVendor', + 'vendor_code' => 'getVendorCode', + 'description' => 'getDescription', + 'id' => 'getId', + 'feed_id' => 'getFeedId', + 'barcodes' => 'getBarcodes', + 'urls' => 'getUrls', + 'pictures' => 'getPictures', + 'manufacturer' => 'getManufacturer', + 'manufacturer_countries' => 'getManufacturerCountries', + 'min_shipment' => 'getMinShipment', + 'transport_unit_size' => 'getTransportUnitSize', + 'quantum_of_supply' => 'getQuantumOfSupply', + 'delivery_duration_days' => 'getDeliveryDurationDays', + 'box_count' => 'getBoxCount', + 'customs_commodity_codes' => 'getCustomsCommodityCodes', + 'weight_dimensions' => 'getWeightDimensions', + 'supply_schedule_days' => 'getSupplyScheduleDays', + 'shelf_life_days' => 'getShelfLifeDays', + 'life_time_days' => 'getLifeTimeDays', + 'guarantee_period_days' => 'getGuaranteePeriodDays', + 'processing_state' => 'getProcessingState', + 'availability' => 'getAvailability', + 'shelf_life' => 'getShelfLife', + 'life_time' => 'getLifeTime', + 'guarantee_period' => 'getGuaranteePeriod', + 'certificate' => 'getCertificate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('shop_sku', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); + $this->setIfExists('vendor', $data ?? [], null); + $this->setIfExists('vendor_code', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('feed_id', $data ?? [], null); + $this->setIfExists('barcodes', $data ?? [], null); + $this->setIfExists('urls', $data ?? [], null); + $this->setIfExists('pictures', $data ?? [], null); + $this->setIfExists('manufacturer', $data ?? [], null); + $this->setIfExists('manufacturer_countries', $data ?? [], null); + $this->setIfExists('min_shipment', $data ?? [], null); + $this->setIfExists('transport_unit_size', $data ?? [], null); + $this->setIfExists('quantum_of_supply', $data ?? [], null); + $this->setIfExists('delivery_duration_days', $data ?? [], null); + $this->setIfExists('box_count', $data ?? [], null); + $this->setIfExists('customs_commodity_codes', $data ?? [], null); + $this->setIfExists('weight_dimensions', $data ?? [], null); + $this->setIfExists('supply_schedule_days', $data ?? [], null); + $this->setIfExists('shelf_life_days', $data ?? [], null); + $this->setIfExists('life_time_days', $data ?? [], null); + $this->setIfExists('guarantee_period_days', $data ?? [], null); + $this->setIfExists('processing_state', $data ?? [], null); + $this->setIfExists('availability', $data ?? [], null); + $this->setIfExists('shelf_life', $data ?? [], null); + $this->setIfExists('life_time', $data ?? [], null); + $this->setIfExists('guarantee_period', $data ?? [], null); + $this->setIfExists('certificate', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 256)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) > 255)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['shop_sku']) && (mb_strlen($this->container['shop_sku']) < 1)) { + $invalidProperties[] = "invalid value for 'shop_sku', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['shop_sku']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['shop_sku'])) { + $invalidProperties[] = "invalid value for 'shop_sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 6000)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 6000."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) > 255)) { + $invalidProperties[] = "invalid value for 'id', the character length must be smaller than or equal to 255."; + } + + if (!is_null($this->container['id']) && (mb_strlen($this->container['id']) < 1)) { + $invalidProperties[] = "invalid value for 'id', the character length must be bigger than or equal to 1."; + } + + if (!is_null($this->container['id']) && !preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['id'])) { + $invalidProperties[] = "invalid value for 'id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Составляйте название по схеме: тип + бренд или производитель + модель + особенности, если есть (например, цвет, размер или вес) и количество в упаковке. Не включайте в название условия продажи (например, «скидка», «бесплатная доставка» и т. д.), эмоциональные характеристики («хит», «супер» и т. д.). Не пишите слова большими буквами — кроме устоявшихся названий брендов и моделей. Оптимальная длина — 50–60 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/title.html) + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + if ((mb_strlen($name) > 256)) { + throw new \InvalidArgumentException('invalid length for $name when calling UpdateMappingsOfferDTO., must be smaller than or equal to 256.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets shop_sku + * + * @return string|null + */ + public function getShopSku() + { + return $this->container['shop_sku']; + } + + /** + * Sets shop_sku + * + * @param string|null $shop_sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setShopSku($shop_sku) + { + if (is_null($shop_sku)) { + throw new \InvalidArgumentException('non-nullable shop_sku cannot be null'); + } + if ((mb_strlen($shop_sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling UpdateMappingsOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($shop_sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $shop_sku when calling UpdateMappingsOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($shop_sku)))) { + throw new \InvalidArgumentException("invalid value for \$shop_sku when calling UpdateMappingsOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['shop_sku'] = $shop_sku; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category Категория товара в вашем магазине. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. Указывайте конкретные категории — например, набор ножей лучше отнести к категории **Столовые приборы**, а не просто **Посуда**. Выбирайте категории, которые описывают товар, а не абстрактный признак — например, **Духи**, а не **Подарки**. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. + * + * @return self + */ + public function setCategory($category) + { + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets vendor + * + * @return string|null + */ + public function getVendor() + { + return $this->container['vendor']; + } + + /** + * Sets vendor + * + * @param string|null $vendor Название бренда или производителя. Должно быть записано так, как его пишет сам бренд. + * + * @return self + */ + public function setVendor($vendor) + { + if (is_null($vendor)) { + throw new \InvalidArgumentException('non-nullable vendor cannot be null'); + } + $this->container['vendor'] = $vendor; + + return $this; + } + + /** + * Gets vendor_code + * + * @return string|null + */ + public function getVendorCode() + { + return $this->container['vendor_code']; + } + + /** + * Sets vendor_code + * + * @param string|null $vendor_code Артикул товара от производителя. + * + * @return self + */ + public function setVendorCode($vendor_code) + { + if (is_null($vendor_code)) { + throw new \InvalidArgumentException('non-nullable vendor_code cannot be null'); + } + $this->container['vendor_code'] = $vendor_code; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Подробное описание товара: например, его преимущества и особенности. Не давайте в описании инструкций по установке и сборке. Не используйте слова «скидка», «распродажа», «дешевый», «подарок» (кроме подарочных категорий), «бесплатно», «акция», «специальная цена», «новинка», «new», «аналог», «заказ», «хит». Не указывайте никакой контактной информации и не давайте ссылок. Можно использовать теги: * \\, \\

                                                  , \\

                                                  и так далее — для заголовков; * \\
                                                  и \\

                                                  — для переноса строки; * \\

                                                    — для нумерованного списка; * \\
                                                      — для маркированного списка; * \\
                                                    • — для создания элементов списка (должен находиться внутри \\
                                                        или \\
                                                          ); * \\
                                                          — поддерживается, но не влияет на отображение текста. Оптимальная длина — 400–600 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/description.html) + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + if ((mb_strlen($description) > 6000)) { + throw new \InvalidArgumentException('invalid length for $description when calling UpdateMappingsOfferDTO., must be smaller than or equal to 6000.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + if ((mb_strlen($id) > 255)) { + throw new \InvalidArgumentException('invalid length for $id when calling UpdateMappingsOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($id) < 1)) { + throw new \InvalidArgumentException('invalid length for $id when calling UpdateMappingsOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($id)))) { + throw new \InvalidArgumentException("invalid value for \$id when calling UpdateMappingsOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets feed_id + * + * @return int|null + */ + public function getFeedId() + { + return $this->container['feed_id']; + } + + /** + * Sets feed_id + * + * @param int|null $feed_id Идентификатор фида. + * + * @return self + */ + public function setFeedId($feed_id) + { + if (is_null($feed_id)) { + throw new \InvalidArgumentException('non-nullable feed_id cannot be null'); + } + $this->container['feed_id'] = $feed_id; + + return $this; + } + + /** + * Gets barcodes + * + * @return string[]|null + */ + public function getBarcodes() + { + return $this->container['barcodes']; + } + + /** + * Sets barcodes + * + * @param string[]|null $barcodes Указывайте в виде последовательности цифр. Подойдут коды EAN-13, EAN-8, UPC-A, UPC-E или Code 128. Для книг указывайте ISBN. Для товаров [определенных категорий и торговых марок](https://yastatic.net/s3/doc-binary/src/support/market/ru/yandex-market-list-for-gtin.xlsx) штрихкод должен быть действительным кодом GTIN. Обратите внимание: внутренние штрихкоды, начинающиеся на 2 или 02, и коды формата Code 128 не являются GTIN. [Что такое GTIN](*gtin) + * + * @return self + */ + public function setBarcodes($barcodes) + { + if (is_null($barcodes)) { + array_push($this->openAPINullablesSetToNull, 'barcodes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('barcodes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['barcodes'] = $barcodes; + + return $this; + } + + /** + * Gets urls + * + * @return string[]|null + */ + public function getUrls() + { + return $this->container['urls']; + } + + /** + * Sets urls + * + * @param string[]|null $urls URL фотографии товара или страницы с описанием на вашем сайте. Переданные данные не будут отображаться на витрине, но они помогут специалистам Маркета найти карточку для вашего товара. Должен содержать один вложенный параметр url. + * + * @return self + */ + public function setUrls($urls) + { + if (is_null($urls)) { + array_push($this->openAPINullablesSetToNull, 'urls'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('urls', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['urls'] = $urls; + + return $this; + } + + /** + * Gets pictures + * + * @return string[]|null + */ + public function getPictures() + { + return $this->container['pictures']; + } + + /** + * Sets pictures + * + * @param string[]|null $pictures Ссылки (URL) изображений товара в хорошем качестве. Можно указать до 30 ссылок. При этом изображение по первой ссылке будет основным. Оно используется в качестве изображения товара в поиске Маркета и на карточке товара. Другие изображения товара доступны в режиме просмотра увеличенных изображений. Обязательный параметр. Должен содержать хотя бы один вложенный параметр `picture`. + * + * @return self + */ + public function setPictures($pictures) + { + if (is_null($pictures)) { + array_push($this->openAPINullablesSetToNull, 'pictures'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('pictures', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['pictures'] = $pictures; + + return $this; + } + + /** + * Gets manufacturer + * + * @return string|null + */ + public function getManufacturer() + { + return $this->container['manufacturer']; + } + + /** + * Sets manufacturer + * + * @param string|null $manufacturer Изготовитель товара: компания, которая произвела товар, ее адрес и регистрационный номер (если есть). Необязательный параметр. + * + * @return self + */ + public function setManufacturer($manufacturer) + { + if (is_null($manufacturer)) { + throw new \InvalidArgumentException('non-nullable manufacturer cannot be null'); + } + $this->container['manufacturer'] = $manufacturer; + + return $this; + } + + /** + * Gets manufacturer_countries + * + * @return string[]|null + */ + public function getManufacturerCountries() + { + return $this->container['manufacturer_countries']; + } + + /** + * Sets manufacturer_countries + * + * @param string[]|null $manufacturer_countries Список стран, в которых произведен товар. Обязательный параметр. Должен содержать хотя бы одну, но не больше 5 стран. + * + * @return self + */ + public function setManufacturerCountries($manufacturer_countries) + { + if (is_null($manufacturer_countries)) { + array_push($this->openAPINullablesSetToNull, 'manufacturer_countries'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manufacturer_countries', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['manufacturer_countries'] = $manufacturer_countries; + + return $this; + } + + /** + * Gets min_shipment + * + * @return int|null + */ + public function getMinShipment() + { + return $this->container['min_shipment']; + } + + /** + * Sets min_shipment + * + * @param int|null $min_shipment Минимальное количество единиц товара, которое вы поставляете на склад. Например, если вы поставляете детское питание партиями минимум по 10 коробок, а в каждой коробке по 6 баночек, укажите значение 60. + * + * @return self + */ + public function setMinShipment($min_shipment) + { + if (is_null($min_shipment)) { + throw new \InvalidArgumentException('non-nullable min_shipment cannot be null'); + } + $this->container['min_shipment'] = $min_shipment; + + return $this; + } + + /** + * Gets transport_unit_size + * + * @return int|null + */ + public function getTransportUnitSize() + { + return $this->container['transport_unit_size']; + } + + /** + * Sets transport_unit_size + * + * @param int|null $transport_unit_size Количество единиц товара в одной упаковке, которую вы поставляете на склад. Например, если вы поставляете детское питание коробками по 6 баночек, укажите значение 6. + * + * @return self + */ + public function setTransportUnitSize($transport_unit_size) + { + if (is_null($transport_unit_size)) { + throw new \InvalidArgumentException('non-nullable transport_unit_size cannot be null'); + } + $this->container['transport_unit_size'] = $transport_unit_size; + + return $this; + } + + /** + * Gets quantum_of_supply + * + * @return int|null + */ + public function getQuantumOfSupply() + { + return $this->container['quantum_of_supply']; + } + + /** + * Sets quantum_of_supply + * + * @param int|null $quantum_of_supply Добавочная партия: по сколько единиц товара можно добавлять к минимальному количеству minShipment. Например, если вы поставляете детское питание партиями минимум по 10 коробок и хотите добавлять к минимальной партии по 2 коробки, а в каждой коробке по 6 баночек, укажите значение 12. + * + * @return self + */ + public function setQuantumOfSupply($quantum_of_supply) + { + if (is_null($quantum_of_supply)) { + throw new \InvalidArgumentException('non-nullable quantum_of_supply cannot be null'); + } + $this->container['quantum_of_supply'] = $quantum_of_supply; + + return $this; + } + + /** + * Gets delivery_duration_days + * + * @return int|null + */ + public function getDeliveryDurationDays() + { + return $this->container['delivery_duration_days']; + } + + /** + * Sets delivery_duration_days + * + * @param int|null $delivery_duration_days Срок, за который продавец поставляет товары на склад, в днях. + * + * @return self + */ + public function setDeliveryDurationDays($delivery_duration_days) + { + if (is_null($delivery_duration_days)) { + throw new \InvalidArgumentException('non-nullable delivery_duration_days cannot be null'); + } + $this->container['delivery_duration_days'] = $delivery_duration_days; + + return $this; + } + + /** + * Gets box_count + * + * @return int|null + */ + public function getBoxCount() + { + return $this->container['box_count']; + } + + /** + * Sets box_count + * + * @param int|null $box_count Сколько мест (если больше одного) занимает товар. Параметр указывается, только если товар занимает больше одного места (например, кондиционер занимает два места: внешний и внутренний блоки в двух коробках). Если товар занимает одно место, не указывайте этот параметр. + * + * @return self + */ + public function setBoxCount($box_count) + { + if (is_null($box_count)) { + throw new \InvalidArgumentException('non-nullable box_count cannot be null'); + } + $this->container['box_count'] = $box_count; + + return $this; + } + + /** + * Gets customs_commodity_codes + * + * @return string[]|null + */ + public function getCustomsCommodityCodes() + { + return $this->container['customs_commodity_codes']; + } + + /** + * Sets customs_commodity_codes + * + * @param string[]|null $customs_commodity_codes Список кодов товара в единой Товарной номенклатуре внешнеэкономической деятельности (ТН ВЭД). Обязательный параметр, если товар подлежит особому учету (например, в системе «Меркурий» как продукция животного происхождения или в системе «Честный ЗНАК»). Может содержать только один вложенный код ТН ВЭД. + * + * @return self + */ + public function setCustomsCommodityCodes($customs_commodity_codes) + { + if (is_null($customs_commodity_codes)) { + array_push($this->openAPINullablesSetToNull, 'customs_commodity_codes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('customs_commodity_codes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['customs_commodity_codes'] = $customs_commodity_codes; + + return $this; + } + + /** + * Gets weight_dimensions + * + * @return \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null + */ + public function getWeightDimensions() + { + return $this->container['weight_dimensions']; + } + + /** + * Sets weight_dimensions + * + * @param \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null $weight_dimensions weight_dimensions + * + * @return self + */ + public function setWeightDimensions($weight_dimensions) + { + if (is_null($weight_dimensions)) { + throw new \InvalidArgumentException('non-nullable weight_dimensions cannot be null'); + } + $this->container['weight_dimensions'] = $weight_dimensions; + + return $this; + } + + /** + * Gets supply_schedule_days + * + * @return \OpenAPI\Client\Model\DayOfWeekType[]|null + */ + public function getSupplyScheduleDays() + { + return $this->container['supply_schedule_days']; + } + + /** + * Sets supply_schedule_days + * + * @param \OpenAPI\Client\Model\DayOfWeekType[]|null $supply_schedule_days Дни недели, в которые продавец поставляет товары на склад. + * + * @return self + */ + public function setSupplyScheduleDays($supply_schedule_days) + { + if (is_null($supply_schedule_days)) { + array_push($this->openAPINullablesSetToNull, 'supply_schedule_days'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('supply_schedule_days', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['supply_schedule_days'] = $supply_schedule_days; + + return $this; + } + + /** + * Gets shelf_life_days + * + * @return int|null + */ + public function getShelfLifeDays() + { + return $this->container['shelf_life_days']; + } + + /** + * Sets shelf_life_days + * + * @param int|null $shelf_life_days {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `shelfLife`. Совместное использование обоих параметров приведет к ошибке. {% endnote %} Срок годности: через сколько дней товар станет непригоден для использования. + * + * @return self + */ + public function setShelfLifeDays($shelf_life_days) + { + if (is_null($shelf_life_days)) { + throw new \InvalidArgumentException('non-nullable shelf_life_days cannot be null'); + } + $this->container['shelf_life_days'] = $shelf_life_days; + + return $this; + } + + /** + * Gets life_time_days + * + * @return int|null + */ + public function getLifeTimeDays() + { + return $this->container['life_time_days']; + } + + /** + * Sets life_time_days + * + * @param int|null $life_time_days {% note warning \"\" %} Этот параметр устарел. Вместо него используйте `lifeTime`. Совместное использование обоих параметров приведет к ошибке. {% endnote %} Срок службы: сколько дней товар будет исправно выполнять свою функцию, а изготовитель — нести ответственность за его существенные недостатки. + * + * @return self + */ + public function setLifeTimeDays($life_time_days) + { + if (is_null($life_time_days)) { + throw new \InvalidArgumentException('non-nullable life_time_days cannot be null'); + } + $this->container['life_time_days'] = $life_time_days; + + return $this; + } + + /** + * Gets guarantee_period_days + * + * @return int|null + */ + public function getGuaranteePeriodDays() + { + return $this->container['guarantee_period_days']; + } + + /** + * Sets guarantee_period_days + * + * @param int|null $guarantee_period_days Гарантийный срок товара: сколько дней возможно обслуживание и ремонт товара или возврат денег, а изготовитель или продавец будет нести ответственность за недостатки товара. + * + * @return self + */ + public function setGuaranteePeriodDays($guarantee_period_days) + { + if (is_null($guarantee_period_days)) { + throw new \InvalidArgumentException('non-nullable guarantee_period_days cannot be null'); + } + $this->container['guarantee_period_days'] = $guarantee_period_days; + + return $this; + } + + /** + * Gets processing_state + * + * @return \OpenAPI\Client\Model\OfferProcessingStateDTO|null + */ + public function getProcessingState() + { + return $this->container['processing_state']; + } + + /** + * Sets processing_state + * + * @param \OpenAPI\Client\Model\OfferProcessingStateDTO|null $processing_state processing_state + * + * @return self + */ + public function setProcessingState($processing_state) + { + if (is_null($processing_state)) { + throw new \InvalidArgumentException('non-nullable processing_state cannot be null'); + } + $this->container['processing_state'] = $processing_state; + + return $this; + } + + /** + * Gets availability + * + * @return \OpenAPI\Client\Model\OfferAvailabilityStatusType|null + */ + public function getAvailability() + { + return $this->container['availability']; + } + + /** + * Sets availability + * + * @param \OpenAPI\Client\Model\OfferAvailabilityStatusType|null $availability availability + * + * @return self + */ + public function setAvailability($availability) + { + if (is_null($availability)) { + throw new \InvalidArgumentException('non-nullable availability cannot be null'); + } + $this->container['availability'] = $availability; + + return $this; + } + + /** + * Gets shelf_life + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getShelfLife() + { + return $this->container['shelf_life']; + } + + /** + * Sets shelf_life + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $shelf_life shelf_life + * + * @return self + */ + public function setShelfLife($shelf_life) + { + if (is_null($shelf_life)) { + throw new \InvalidArgumentException('non-nullable shelf_life cannot be null'); + } + $this->container['shelf_life'] = $shelf_life; + + return $this; + } + + /** + * Gets life_time + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getLifeTime() + { + return $this->container['life_time']; + } + + /** + * Sets life_time + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $life_time life_time + * + * @return self + */ + public function setLifeTime($life_time) + { + if (is_null($life_time)) { + throw new \InvalidArgumentException('non-nullable life_time cannot be null'); + } + $this->container['life_time'] = $life_time; + + return $this; + } + + /** + * Gets guarantee_period + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getGuaranteePeriod() + { + return $this->container['guarantee_period']; + } + + /** + * Sets guarantee_period + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $guarantee_period guarantee_period + * + * @return self + */ + public function setGuaranteePeriod($guarantee_period) + { + if (is_null($guarantee_period)) { + throw new \InvalidArgumentException('non-nullable guarantee_period cannot be null'); + } + $this->container['guarantee_period'] = $guarantee_period; + + return $this; + } + + /** + * Gets certificate + * + * @return string|null + */ + public function getCertificate() + { + return $this->container['certificate']; + } + + /** + * Sets certificate + * + * @param string|null $certificate Номер документа на товар. Перед указанием номера документ нужно загрузить в кабинете продавца на Маркете. [Инструкция](https://yandex.ru/support/marketplace/assortment/restrictions/certificates.html) + * + * @return self + */ + public function setCertificate($certificate) + { + if (is_null($certificate)) { + throw new \InvalidArgumentException('non-nullable certificate cannot be null'); + } + $this->container['certificate'] = $certificate; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferContentRequest.php b/erp24/lib/yandex_market_api/Model/UpdateOfferContentRequest.php new file mode 100644 index 00000000..25bab85f --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferContentRequest.php @@ -0,0 +1,428 @@ + + */ +class UpdateOfferContentRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferContentRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers_content' => '\OpenAPI\Client\Model\OfferContentDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers_content' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers_content' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers_content' => 'offersContent' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers_content' => 'setOffersContent' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers_content' => 'getOffersContent' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers_content', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers_content'] === null) { + $invalidProperties[] = "'offers_content' can't be null"; + } + if ((count($this->container['offers_content']) > 100)) { + $invalidProperties[] = "invalid value for 'offers_content', number of items must be less than or equal to 100."; + } + + if ((count($this->container['offers_content']) < 1)) { + $invalidProperties[] = "invalid value for 'offers_content', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers_content + * + * @return \OpenAPI\Client\Model\OfferContentDTO[] + */ + public function getOffersContent() + { + return $this->container['offers_content']; + } + + /** + * Sets offers_content + * + * @param \OpenAPI\Client\Model\OfferContentDTO[] $offers_content Список товаров с указанными характеристиками. + * + * @return self + */ + public function setOffersContent($offers_content) + { + if (is_null($offers_content)) { + throw new \InvalidArgumentException('non-nullable offers_content cannot be null'); + } + + if ((count($offers_content) > 100)) { + throw new \InvalidArgumentException('invalid value for $offers_content when calling UpdateOfferContentRequest., number of items must be less than or equal to 100.'); + } + if ((count($offers_content) < 1)) { + throw new \InvalidArgumentException('invalid length for $offers_content when calling UpdateOfferContentRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offers_content'] = $offers_content; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferContentResponse.php b/erp24/lib/yandex_market_api/Model/UpdateOfferContentResponse.php new file mode 100644 index 00000000..8295c58c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferContentResponse.php @@ -0,0 +1,451 @@ + + */ +class UpdateOfferContentResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferContentResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'results' => '\OpenAPI\Client\Model\UpdateOfferContentResultDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'results' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'results' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'results' => 'results' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'results' => 'setResults' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'results' => 'getResults' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('results', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets results + * + * @return \OpenAPI\Client\Model\UpdateOfferContentResultDTO[]|null + */ + public function getResults() + { + return $this->container['results']; + } + + /** + * Sets results + * + * @param \OpenAPI\Client\Model\UpdateOfferContentResultDTO[]|null $results Ошибки и предупреждения, которые появились при обработке переданных значений. Каждый элемент списка соответствует одному товару. Если ошибок и предупреждений нет, поле не передается. + * + * @return self + */ + public function setResults($results) + { + if (is_null($results)) { + array_push($this->openAPINullablesSetToNull, 'results'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('results', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['results'] = $results; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferContentResultDTO.php b/erp24/lib/yandex_market_api/Model/UpdateOfferContentResultDTO.php new file mode 100644 index 00000000..9f249db9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferContentResultDTO.php @@ -0,0 +1,517 @@ + + */ +class UpdateOfferContentResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferContentResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'errors' => '\OpenAPI\Client\Model\OfferContentErrorDTO[]', + 'warnings' => '\OpenAPI\Client\Model\OfferContentErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'errors' => null, + 'warnings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'errors' => true, + 'warnings' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'errors' => 'errors', + 'warnings' => 'warnings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'errors' => 'setErrors', + 'warnings' => 'setWarnings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'errors' => 'getErrors', + 'warnings' => 'getWarnings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateOfferContentResultDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateOfferContentResultDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling UpdateOfferContentResultDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\OfferContentErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\OfferContentErrorDTO[]|null $errors Ошибки — информация в каталоге не обновится. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + + /** + * Gets warnings + * + * @return \OpenAPI\Client\Model\OfferContentErrorDTO[]|null + */ + public function getWarnings() + { + return $this->container['warnings']; + } + + /** + * Sets warnings + * + * @param \OpenAPI\Client\Model\OfferContentErrorDTO[]|null $warnings Предупреждения — информация в каталоге обновится. + * + * @return self + */ + public function setWarnings($warnings) + { + if (is_null($warnings)) { + array_push($this->openAPINullablesSetToNull, 'warnings'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('warnings', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['warnings'] = $warnings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferDTO.php b/erp24/lib/yandex_market_api/Model/UpdateOfferDTO.php new file mode 100644 index 00000000..f1bbad7c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferDTO.php @@ -0,0 +1,1560 @@ + + */ +class UpdateOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'name' => 'string', + 'market_category_id' => 'int', + 'category' => 'string', + 'pictures' => 'string[]', + 'videos' => 'string[]', + 'manuals' => '\OpenAPI\Client\Model\OfferManualDTO[]', + 'vendor' => 'string', + 'barcodes' => 'string[]', + 'description' => 'string', + 'manufacturer_countries' => 'string[]', + 'weight_dimensions' => '\OpenAPI\Client\Model\OfferWeightDimensionsDTO', + 'vendor_code' => 'string', + 'tags' => 'string[]', + 'shelf_life' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'life_time' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'guarantee_period' => '\OpenAPI\Client\Model\TimePeriodDTO', + 'customs_commodity_code' => 'string', + 'certificates' => 'string[]', + 'box_count' => 'int', + 'condition' => '\OpenAPI\Client\Model\OfferConditionDTO', + 'type' => '\OpenAPI\Client\Model\OfferType', + 'downloadable' => 'bool', + 'adult' => 'bool', + 'age' => '\OpenAPI\Client\Model\AgeDTO', + 'params' => '\OpenAPI\Client\Model\OfferParamDTO[]', + 'parameter_values' => '\OpenAPI\Client\Model\ParameterValueDTO[]', + 'basic_price' => '\OpenAPI\Client\Model\UpdatePriceWithDiscountDTO', + 'purchase_price' => '\OpenAPI\Client\Model\BasePriceDTO', + 'additional_expenses' => '\OpenAPI\Client\Model\BasePriceDTO', + 'cofinance_price' => '\OpenAPI\Client\Model\BasePriceDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'name' => null, + 'market_category_id' => 'int64', + 'category' => null, + 'pictures' => null, + 'videos' => null, + 'manuals' => null, + 'vendor' => null, + 'barcodes' => null, + 'description' => null, + 'manufacturer_countries' => null, + 'weight_dimensions' => null, + 'vendor_code' => null, + 'tags' => null, + 'shelf_life' => null, + 'life_time' => null, + 'guarantee_period' => null, + 'customs_commodity_code' => null, + 'certificates' => null, + 'box_count' => 'int32', + 'condition' => null, + 'type' => null, + 'downloadable' => null, + 'adult' => null, + 'age' => null, + 'params' => null, + 'parameter_values' => null, + 'basic_price' => null, + 'purchase_price' => null, + 'additional_expenses' => null, + 'cofinance_price' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'name' => false, + 'market_category_id' => false, + 'category' => false, + 'pictures' => true, + 'videos' => true, + 'manuals' => true, + 'vendor' => false, + 'barcodes' => true, + 'description' => false, + 'manufacturer_countries' => true, + 'weight_dimensions' => false, + 'vendor_code' => false, + 'tags' => true, + 'shelf_life' => false, + 'life_time' => false, + 'guarantee_period' => false, + 'customs_commodity_code' => false, + 'certificates' => true, + 'box_count' => false, + 'condition' => false, + 'type' => false, + 'downloadable' => false, + 'adult' => false, + 'age' => false, + 'params' => true, + 'parameter_values' => true, + 'basic_price' => false, + 'purchase_price' => false, + 'additional_expenses' => false, + 'cofinance_price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'name' => 'name', + 'market_category_id' => 'marketCategoryId', + 'category' => 'category', + 'pictures' => 'pictures', + 'videos' => 'videos', + 'manuals' => 'manuals', + 'vendor' => 'vendor', + 'barcodes' => 'barcodes', + 'description' => 'description', + 'manufacturer_countries' => 'manufacturerCountries', + 'weight_dimensions' => 'weightDimensions', + 'vendor_code' => 'vendorCode', + 'tags' => 'tags', + 'shelf_life' => 'shelfLife', + 'life_time' => 'lifeTime', + 'guarantee_period' => 'guaranteePeriod', + 'customs_commodity_code' => 'customsCommodityCode', + 'certificates' => 'certificates', + 'box_count' => 'boxCount', + 'condition' => 'condition', + 'type' => 'type', + 'downloadable' => 'downloadable', + 'adult' => 'adult', + 'age' => 'age', + 'params' => 'params', + 'parameter_values' => 'parameterValues', + 'basic_price' => 'basicPrice', + 'purchase_price' => 'purchasePrice', + 'additional_expenses' => 'additionalExpenses', + 'cofinance_price' => 'cofinancePrice' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'name' => 'setName', + 'market_category_id' => 'setMarketCategoryId', + 'category' => 'setCategory', + 'pictures' => 'setPictures', + 'videos' => 'setVideos', + 'manuals' => 'setManuals', + 'vendor' => 'setVendor', + 'barcodes' => 'setBarcodes', + 'description' => 'setDescription', + 'manufacturer_countries' => 'setManufacturerCountries', + 'weight_dimensions' => 'setWeightDimensions', + 'vendor_code' => 'setVendorCode', + 'tags' => 'setTags', + 'shelf_life' => 'setShelfLife', + 'life_time' => 'setLifeTime', + 'guarantee_period' => 'setGuaranteePeriod', + 'customs_commodity_code' => 'setCustomsCommodityCode', + 'certificates' => 'setCertificates', + 'box_count' => 'setBoxCount', + 'condition' => 'setCondition', + 'type' => 'setType', + 'downloadable' => 'setDownloadable', + 'adult' => 'setAdult', + 'age' => 'setAge', + 'params' => 'setParams', + 'parameter_values' => 'setParameterValues', + 'basic_price' => 'setBasicPrice', + 'purchase_price' => 'setPurchasePrice', + 'additional_expenses' => 'setAdditionalExpenses', + 'cofinance_price' => 'setCofinancePrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'name' => 'getName', + 'market_category_id' => 'getMarketCategoryId', + 'category' => 'getCategory', + 'pictures' => 'getPictures', + 'videos' => 'getVideos', + 'manuals' => 'getManuals', + 'vendor' => 'getVendor', + 'barcodes' => 'getBarcodes', + 'description' => 'getDescription', + 'manufacturer_countries' => 'getManufacturerCountries', + 'weight_dimensions' => 'getWeightDimensions', + 'vendor_code' => 'getVendorCode', + 'tags' => 'getTags', + 'shelf_life' => 'getShelfLife', + 'life_time' => 'getLifeTime', + 'guarantee_period' => 'getGuaranteePeriod', + 'customs_commodity_code' => 'getCustomsCommodityCode', + 'certificates' => 'getCertificates', + 'box_count' => 'getBoxCount', + 'condition' => 'getCondition', + 'type' => 'getType', + 'downloadable' => 'getDownloadable', + 'adult' => 'getAdult', + 'age' => 'getAge', + 'params' => 'getParams', + 'parameter_values' => 'getParameterValues', + 'basic_price' => 'getBasicPrice', + 'purchase_price' => 'getPurchasePrice', + 'additional_expenses' => 'getAdditionalExpenses', + 'cofinance_price' => 'getCofinancePrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('market_category_id', $data ?? [], null); + $this->setIfExists('category', $data ?? [], null); + $this->setIfExists('pictures', $data ?? [], null); + $this->setIfExists('videos', $data ?? [], null); + $this->setIfExists('manuals', $data ?? [], null); + $this->setIfExists('vendor', $data ?? [], null); + $this->setIfExists('barcodes', $data ?? [], null); + $this->setIfExists('description', $data ?? [], null); + $this->setIfExists('manufacturer_countries', $data ?? [], null); + $this->setIfExists('weight_dimensions', $data ?? [], null); + $this->setIfExists('vendor_code', $data ?? [], null); + $this->setIfExists('tags', $data ?? [], null); + $this->setIfExists('shelf_life', $data ?? [], null); + $this->setIfExists('life_time', $data ?? [], null); + $this->setIfExists('guarantee_period', $data ?? [], null); + $this->setIfExists('customs_commodity_code', $data ?? [], null); + $this->setIfExists('certificates', $data ?? [], null); + $this->setIfExists('box_count', $data ?? [], null); + $this->setIfExists('condition', $data ?? [], null); + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('downloadable', $data ?? [], null); + $this->setIfExists('adult', $data ?? [], null); + $this->setIfExists('age', $data ?? [], null); + $this->setIfExists('params', $data ?? [], null); + $this->setIfExists('parameter_values', $data ?? [], null); + $this->setIfExists('basic_price', $data ?? [], null); + $this->setIfExists('purchase_price', $data ?? [], null); + $this->setIfExists('additional_expenses', $data ?? [], null); + $this->setIfExists('cofinance_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if (!is_null($this->container['name']) && (mb_strlen($this->container['name']) > 256)) { + $invalidProperties[] = "invalid value for 'name', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['videos']) && (count($this->container['videos']) > 6)) { + $invalidProperties[] = "invalid value for 'videos', number of items must be less than or equal to 6."; + } + + if (!is_null($this->container['manuals']) && (count($this->container['manuals']) > 6)) { + $invalidProperties[] = "invalid value for 'manuals', number of items must be less than or equal to 6."; + } + + if (!is_null($this->container['description']) && (mb_strlen($this->container['description']) > 6000)) { + $invalidProperties[] = "invalid value for 'description', the character length must be smaller than or equal to 6000."; + } + + if (!is_null($this->container['parameter_values']) && (count($this->container['parameter_values']) > 300)) { + $invalidProperties[] = "invalid value for 'parameter_values', number of items must be less than or equal to 300."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling UpdateOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Составляйте название по схеме: тип + бренд или производитель + модель + особенности, если есть (например, цвет, размер или вес) и количество в упаковке. Не включайте в название условия продажи (например, «скидка», «бесплатная доставка» и т. д.), эмоциональные характеристики («хит», «супер» и т. д.). Не пишите слова большими буквами — кроме устоявшихся названий брендов и моделей. Оптимальная длина — 50–60 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/title.html) + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + if ((mb_strlen($name) > 256)) { + throw new \InvalidArgumentException('invalid length for $name when calling UpdateOfferDTO., must be smaller than or equal to 256.'); + } + + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets market_category_id + * + * @return int|null + */ + public function getMarketCategoryId() + { + return $this->container['market_category_id']; + } + + /** + * Sets market_category_id + * + * @param int|null $market_category_id Идентификатор категории на Маркете, к которой вы относите свой товар. Если не указать `marketCategoryId`, то маркетная категория будет определена автоматически. При изменении информации о товаре передавайте тот же идентификатор категории. Если вы укажете другой, категория товара не поменяется. Изменить ее можно только в кабинете продавца на Маркете. Список категорий Маркета можно получить с помощью запроса [POST categories/tree](../../reference/categories/getCategoriesTree.md). + * + * @return self + */ + public function setMarketCategoryId($market_category_id) + { + if (is_null($market_category_id)) { + throw new \InvalidArgumentException('non-nullable market_category_id cannot be null'); + } + $this->container['market_category_id'] = $market_category_id; + + return $this; + } + + /** + * Gets category + * + * @return string|null + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string|null $category Категория товара в вашем магазине. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. Указывайте конкретные категории — например, набор ножей лучше отнести к категории **Столовые приборы**, а не просто **Посуда**. Выбирайте категории, которые описывают товар, а не абстрактный признак — например, **Духи**, а не **Подарки**. Значение будет использовано для определения категории товара на Маркете в случае, если вы не передали категорию в параметре `marketCategoryId`. + * + * @return self + */ + public function setCategory($category) + { + if (is_null($category)) { + throw new \InvalidArgumentException('non-nullable category cannot be null'); + } + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets pictures + * + * @return string[]|null + */ + public function getPictures() + { + return $this->container['pictures']; + } + + /** + * Sets pictures + * + * @param string[]|null $pictures Ссылки на изображения товара. Изображение по первой ссылке считается основным, остальные дополнительными. **Требования к ссылкам** * Ссылок может быть до 30. * Указывайте ссылку целиком, включая протокол http или https. * Максимальная длина — 512 символов. * Русские буквы в URL можно. * Можно использовать прямые ссылки на изображения и на Яндекс Диск. Ссылки на Яндекс Диске нужно копировать с помощью функции **Поделиться**. Относительные ссылки и ссылки на другие облачные хранилища — не работают. ✅ `https://example-shop.ru/images/sku12345.jpg` ✅ `https://yadi.sk/i/NaBoRsimVOLov` ❌ `/images/sku12345.jpg` ❌ `https://www.dropbox.com/s/818f/tovar.jpg` Ссылки на изображение должны быть постоянными. Нельзя использовать динамические ссылки, меняющиеся от выгрузки к выгрузке. Если нужно заменить изображение, выложите новое изображение по новой ссылке, а ссылку на старое удалите. Если просто заменить изображение по старой ссылке, оно не обновится. [Требования к изображениям](https://yandex.ru/support/marketplace/assortment/fields/images.html) + * + * @return self + */ + public function setPictures($pictures) + { + if (is_null($pictures)) { + array_push($this->openAPINullablesSetToNull, 'pictures'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('pictures', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['pictures'] = $pictures; + + return $this; + } + + /** + * Gets videos + * + * @return string[]|null + */ + public function getVideos() + { + return $this->container['videos']; + } + + /** + * Sets videos + * + * @param string[]|null $videos Ссылка (URL) на видео товара. Максимальное количество ссылок — 6. **Требования к ссылке** * Указывайте ссылку целиком, включая протокол http или https. * Максимальная длина — 512 символов. * Русские буквы в URL можно. * Можно использовать прямые ссылки на видео и на Яндекс Диск. Ссылки на Яндекс Диске нужно копировать с помощью функции **Поделиться**. Относительные ссылки и ссылки на другие облачные хранилища — не работают. ✅ `https://example-shop.ru/video/sku12345.avi` ✅ `https://yadi.sk/i/NaBoRsimVOLov` ❌ `/video/sku12345.avi` ❌ `https://www.dropbox.com/s/818f/super-tovar.avi` Ссылки на видео должны быть постоянными. Нельзя использовать динамические ссылки, меняющиеся от выгрузки к выгрузке. Если нужно заменить видео, выложите новое видео по новой ссылке, а ссылку на старое удалите. Если просто заменить видео по старой ссылке, оно не обновится. [Требования к видео](https://yandex.ru/support/marketplace/assortment/fields/video.html) + * + * @return self + */ + public function setVideos($videos) + { + if (is_null($videos)) { + array_push($this->openAPINullablesSetToNull, 'videos'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('videos', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($videos) && (count($videos) > 6)) { + throw new \InvalidArgumentException('invalid value for $videos when calling UpdateOfferDTO., number of items must be less than or equal to 6.'); + } + $this->container['videos'] = $videos; + + return $this; + } + + /** + * Gets manuals + * + * @return \OpenAPI\Client\Model\OfferManualDTO[]|null + */ + public function getManuals() + { + return $this->container['manuals']; + } + + /** + * Sets manuals + * + * @param \OpenAPI\Client\Model\OfferManualDTO[]|null $manuals Список инструкций по использованию товара. Максимальное количество инструкций — 6. Если вы передадите пустое поле `manuals`, загруженные ранее инструкции удалятся. + * + * @return self + */ + public function setManuals($manuals) + { + if (is_null($manuals)) { + array_push($this->openAPINullablesSetToNull, 'manuals'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manuals', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($manuals) && (count($manuals) > 6)) { + throw new \InvalidArgumentException('invalid value for $manuals when calling UpdateOfferDTO., number of items must be less than or equal to 6.'); + } + $this->container['manuals'] = $manuals; + + return $this; + } + + /** + * Gets vendor + * + * @return string|null + */ + public function getVendor() + { + return $this->container['vendor']; + } + + /** + * Sets vendor + * + * @param string|null $vendor Название бренда или производителя. Должно быть записано так, как его пишет сам бренд. + * + * @return self + */ + public function setVendor($vendor) + { + if (is_null($vendor)) { + throw new \InvalidArgumentException('non-nullable vendor cannot be null'); + } + $this->container['vendor'] = $vendor; + + return $this; + } + + /** + * Gets barcodes + * + * @return string[]|null + */ + public function getBarcodes() + { + return $this->container['barcodes']; + } + + /** + * Sets barcodes + * + * @param string[]|null $barcodes Указывайте в виде последовательности цифр. Подойдут коды EAN-13, EAN-8, UPC-A, UPC-E или Code 128. Для книг указывайте ISBN. Для товаров [определенных категорий и торговых марок](https://yastatic.net/s3/doc-binary/src/support/market/ru/yandex-market-list-for-gtin.xlsx) штрихкод должен быть действительным кодом GTIN. Обратите внимание: внутренние штрихкоды, начинающиеся на 2 или 02, и коды формата Code 128 не являются GTIN. [Что такое GTIN](*gtin) + * + * @return self + */ + public function setBarcodes($barcodes) + { + if (is_null($barcodes)) { + array_push($this->openAPINullablesSetToNull, 'barcodes'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('barcodes', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['barcodes'] = $barcodes; + + return $this; + } + + /** + * Gets description + * + * @return string|null + */ + public function getDescription() + { + return $this->container['description']; + } + + /** + * Sets description + * + * @param string|null $description Подробное описание товара: например, его преимущества и особенности. Не давайте в описании инструкций по установке и сборке. Не используйте слова «скидка», «распродажа», «дешевый», «подарок» (кроме подарочных категорий), «бесплатно», «акция», «специальная цена», «новинка», «new», «аналог», «заказ», «хит». Не указывайте никакой контактной информации и не давайте ссылок. Можно использовать теги: * \\, \\

                                                          , \\

                                                          и так далее — для заголовков; * \\
                                                          и \\

                                                          — для переноса строки; * \\

                                                            — для нумерованного списка; * \\
                                                              — для маркированного списка; * \\
                                                            • — для создания элементов списка (должен находиться внутри \\
                                                                или \\
                                                                  ); * \\
                                                                  — поддерживается, но не влияет на отображение текста. Оптимальная длина — 400–600 символов. [Рекомендации и правила](https://yandex.ru/support/marketplace/assortment/fields/description.html) + * + * @return self + */ + public function setDescription($description) + { + if (is_null($description)) { + throw new \InvalidArgumentException('non-nullable description cannot be null'); + } + if ((mb_strlen($description) > 6000)) { + throw new \InvalidArgumentException('invalid length for $description when calling UpdateOfferDTO., must be smaller than or equal to 6000.'); + } + + $this->container['description'] = $description; + + return $this; + } + + /** + * Gets manufacturer_countries + * + * @return string[]|null + */ + public function getManufacturerCountries() + { + return $this->container['manufacturer_countries']; + } + + /** + * Sets manufacturer_countries + * + * @param string[]|null $manufacturer_countries Страна, где был произведен товар. Записывайте названия стран так, как они записаны в [списке](https://yastatic.net/s3/doc-binary/src/support/market/ru/countries.xlsx). + * + * @return self + */ + public function setManufacturerCountries($manufacturer_countries) + { + if (is_null($manufacturer_countries)) { + array_push($this->openAPINullablesSetToNull, 'manufacturer_countries'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('manufacturer_countries', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['manufacturer_countries'] = $manufacturer_countries; + + return $this; + } + + /** + * Gets weight_dimensions + * + * @return \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null + */ + public function getWeightDimensions() + { + return $this->container['weight_dimensions']; + } + + /** + * Sets weight_dimensions + * + * @param \OpenAPI\Client\Model\OfferWeightDimensionsDTO|null $weight_dimensions weight_dimensions + * + * @return self + */ + public function setWeightDimensions($weight_dimensions) + { + if (is_null($weight_dimensions)) { + throw new \InvalidArgumentException('non-nullable weight_dimensions cannot be null'); + } + $this->container['weight_dimensions'] = $weight_dimensions; + + return $this; + } + + /** + * Gets vendor_code + * + * @return string|null + */ + public function getVendorCode() + { + return $this->container['vendor_code']; + } + + /** + * Sets vendor_code + * + * @param string|null $vendor_code Артикул товара от производителя. + * + * @return self + */ + public function setVendorCode($vendor_code) + { + if (is_null($vendor_code)) { + throw new \InvalidArgumentException('non-nullable vendor_code cannot be null'); + } + $this->container['vendor_code'] = $vendor_code; + + return $this; + } + + /** + * Gets tags + * + * @return string[]|null + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param string[]|null $tags Метки товара, используемые магазином. Покупателям теги не видны. По тегам можно группировать и фильтровать разные товары в каталоге — например, товары одной серии, коллекции или линейки. Максимальная длина тега 20 символов. У одного товара может быть максимум 10 тегов. Всего можно создать не больше 50 разных тегов. + * + * @return self + */ + public function setTags($tags) + { + if (is_null($tags)) { + array_push($this->openAPINullablesSetToNull, 'tags'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('tags', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['tags'] = $tags; + + return $this; + } + + /** + * Gets shelf_life + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getShelfLife() + { + return $this->container['shelf_life']; + } + + /** + * Sets shelf_life + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $shelf_life shelf_life + * + * @return self + */ + public function setShelfLife($shelf_life) + { + if (is_null($shelf_life)) { + throw new \InvalidArgumentException('non-nullable shelf_life cannot be null'); + } + $this->container['shelf_life'] = $shelf_life; + + return $this; + } + + /** + * Gets life_time + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getLifeTime() + { + return $this->container['life_time']; + } + + /** + * Sets life_time + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $life_time life_time + * + * @return self + */ + public function setLifeTime($life_time) + { + if (is_null($life_time)) { + throw new \InvalidArgumentException('non-nullable life_time cannot be null'); + } + $this->container['life_time'] = $life_time; + + return $this; + } + + /** + * Gets guarantee_period + * + * @return \OpenAPI\Client\Model\TimePeriodDTO|null + */ + public function getGuaranteePeriod() + { + return $this->container['guarantee_period']; + } + + /** + * Sets guarantee_period + * + * @param \OpenAPI\Client\Model\TimePeriodDTO|null $guarantee_period guarantee_period + * + * @return self + */ + public function setGuaranteePeriod($guarantee_period) + { + if (is_null($guarantee_period)) { + throw new \InvalidArgumentException('non-nullable guarantee_period cannot be null'); + } + $this->container['guarantee_period'] = $guarantee_period; + + return $this; + } + + /** + * Gets customs_commodity_code + * + * @return string|null + */ + public function getCustomsCommodityCode() + { + return $this->container['customs_commodity_code']; + } + + /** + * Sets customs_commodity_code + * + * @param string|null $customs_commodity_code Код товара в единой Товарной номенклатуре внешнеэкономической деятельности (ТН ВЭД) — 10 или 14 цифр без пробелов. Обязательно укажите, если он есть. + * + * @return self + */ + public function setCustomsCommodityCode($customs_commodity_code) + { + if (is_null($customs_commodity_code)) { + throw new \InvalidArgumentException('non-nullable customs_commodity_code cannot be null'); + } + $this->container['customs_commodity_code'] = $customs_commodity_code; + + return $this; + } + + /** + * Gets certificates + * + * @return string[]|null + */ + public function getCertificates() + { + return $this->container['certificates']; + } + + /** + * Sets certificates + * + * @param string[]|null $certificates Номера документов на товар: сертификата, декларации соответствия и т. п. Передавать можно только номера документов, сканы которого загружены в кабинете продавца по [инструкции](https://yandex.ru/support/marketplace/assortment/restrictions/certificates.html). + * + * @return self + */ + public function setCertificates($certificates) + { + if (is_null($certificates)) { + array_push($this->openAPINullablesSetToNull, 'certificates'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('certificates', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['certificates'] = $certificates; + + return $this; + } + + /** + * Gets box_count + * + * @return int|null + */ + public function getBoxCount() + { + return $this->container['box_count']; + } + + /** + * Sets box_count + * + * @param int|null $box_count Количество грузовых мест. Параметр используется, если товар представляет собой несколько коробок, упаковок и так далее. Например, кондиционер занимает два места — внешний и внутренний блоки в двух коробках. Для товаров, занимающих одно место, не передавайте этот параметр. + * + * @return self + */ + public function setBoxCount($box_count) + { + if (is_null($box_count)) { + throw new \InvalidArgumentException('non-nullable box_count cannot be null'); + } + $this->container['box_count'] = $box_count; + + return $this; + } + + /** + * Gets condition + * + * @return \OpenAPI\Client\Model\OfferConditionDTO|null + */ + public function getCondition() + { + return $this->container['condition']; + } + + /** + * Sets condition + * + * @param \OpenAPI\Client\Model\OfferConditionDTO|null $condition condition + * + * @return self + */ + public function setCondition($condition) + { + if (is_null($condition)) { + throw new \InvalidArgumentException('non-nullable condition cannot be null'); + } + $this->container['condition'] = $condition; + + return $this; + } + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\OfferType|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\OfferType|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets downloadable + * + * @return bool|null + */ + public function getDownloadable() + { + return $this->container['downloadable']; + } + + /** + * Sets downloadable + * + * @param bool|null $downloadable Признак цифрового товара. Укажите `true`, если товар доставляется по электронной почте. [Как работать с цифровыми товарами](../../step-by-step/digital.md) + * + * @return self + */ + public function setDownloadable($downloadable) + { + if (is_null($downloadable)) { + throw new \InvalidArgumentException('non-nullable downloadable cannot be null'); + } + $this->container['downloadable'] = $downloadable; + + return $this; + } + + /** + * Gets adult + * + * @return bool|null + */ + public function getAdult() + { + return $this->container['adult']; + } + + /** + * Sets adult + * + * @param bool|null $adult Параметр включает для товара пометку 18+. Устанавливайте ее только для товаров, которые относятся к удовлетворению сексуальных потребностей. + * + * @return self + */ + public function setAdult($adult) + { + if (is_null($adult)) { + throw new \InvalidArgumentException('non-nullable adult cannot be null'); + } + $this->container['adult'] = $adult; + + return $this; + } + + /** + * Gets age + * + * @return \OpenAPI\Client\Model\AgeDTO|null + */ + public function getAge() + { + return $this->container['age']; + } + + /** + * Sets age + * + * @param \OpenAPI\Client\Model\AgeDTO|null $age age + * + * @return self + */ + public function setAge($age) + { + if (is_null($age)) { + throw new \InvalidArgumentException('non-nullable age cannot be null'); + } + $this->container['age'] = $age; + + return $this; + } + + /** + * Gets params + * + * @return \OpenAPI\Client\Model\OfferParamDTO[]|null + * @deprecated + */ + public function getParams() + { + return $this->container['params']; + } + + /** + * Sets params + * + * @param \OpenAPI\Client\Model\OfferParamDTO[]|null $params {% note warning \"\" %} Этот параметр устарел. При передаче характеристик используйте `parameterValues`. {% endnote %} Характеристики, которые есть только у товаров конкретной категории — например, диаметр колес велосипеда или материал подошвы обуви. + * + * @return self + * @deprecated + */ + public function setParams($params) + { + if (is_null($params)) { + array_push($this->openAPINullablesSetToNull, 'params'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('params', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['params'] = $params; + + return $this; + } + + /** + * Gets parameter_values + * + * @return \OpenAPI\Client\Model\ParameterValueDTO[]|null + */ + public function getParameterValues() + { + return $this->container['parameter_values']; + } + + /** + * Sets parameter_values + * + * @param \OpenAPI\Client\Model\ParameterValueDTO[]|null $parameter_values Список характеристик с их значениями. С `parameterValues` обязательно передавайте `marketCategoryId` — идентификатор категории на Маркете, к которой относятся указанные характеристики товара. При **изменении** характеристик передавайте только те, значение которых нужно обновить. Чтобы **удалить** значение заданной характеристики, передайте ее `parameterId` с пустым `value`. Максимальное количество характеристик — 300. + * + * @return self + */ + public function setParameterValues($parameter_values) + { + if (is_null($parameter_values)) { + array_push($this->openAPINullablesSetToNull, 'parameter_values'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('parameter_values', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + + if (!is_null($parameter_values) && (count($parameter_values) > 300)) { + throw new \InvalidArgumentException('invalid value for $parameter_values when calling UpdateOfferDTO., number of items must be less than or equal to 300.'); + } + $this->container['parameter_values'] = $parameter_values; + + return $this; + } + + /** + * Gets basic_price + * + * @return \OpenAPI\Client\Model\UpdatePriceWithDiscountDTO|null + */ + public function getBasicPrice() + { + return $this->container['basic_price']; + } + + /** + * Sets basic_price + * + * @param \OpenAPI\Client\Model\UpdatePriceWithDiscountDTO|null $basic_price basic_price + * + * @return self + */ + public function setBasicPrice($basic_price) + { + if (is_null($basic_price)) { + throw new \InvalidArgumentException('non-nullable basic_price cannot be null'); + } + $this->container['basic_price'] = $basic_price; + + return $this; + } + + /** + * Gets purchase_price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getPurchasePrice() + { + return $this->container['purchase_price']; + } + + /** + * Sets purchase_price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $purchase_price purchase_price + * + * @return self + */ + public function setPurchasePrice($purchase_price) + { + if (is_null($purchase_price)) { + throw new \InvalidArgumentException('non-nullable purchase_price cannot be null'); + } + $this->container['purchase_price'] = $purchase_price; + + return $this; + } + + /** + * Gets additional_expenses + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getAdditionalExpenses() + { + return $this->container['additional_expenses']; + } + + /** + * Sets additional_expenses + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $additional_expenses additional_expenses + * + * @return self + */ + public function setAdditionalExpenses($additional_expenses) + { + if (is_null($additional_expenses)) { + throw new \InvalidArgumentException('non-nullable additional_expenses cannot be null'); + } + $this->container['additional_expenses'] = $additional_expenses; + + return $this; + } + + /** + * Gets cofinance_price + * + * @return \OpenAPI\Client\Model\BasePriceDTO|null + */ + public function getCofinancePrice() + { + return $this->container['cofinance_price']; + } + + /** + * Sets cofinance_price + * + * @param \OpenAPI\Client\Model\BasePriceDTO|null $cofinance_price cofinance_price + * + * @return self + */ + public function setCofinancePrice($cofinance_price) + { + if (is_null($cofinance_price)) { + throw new \InvalidArgumentException('non-nullable cofinance_price cannot be null'); + } + $this->container['cofinance_price'] = $cofinance_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferMappingDTO.php b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingDTO.php new file mode 100644 index 00000000..4b199c19 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingDTO.php @@ -0,0 +1,447 @@ + + */ +class UpdateOfferMappingDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferMappingDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer' => '\OpenAPI\Client\Model\UpdateOfferDTO', + 'mapping' => '\OpenAPI\Client\Model\UpdateMappingDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer' => null, + 'mapping' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer' => false, + 'mapping' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer' => 'offer', + 'mapping' => 'mapping' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer' => 'setOffer', + 'mapping' => 'setMapping' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer' => 'getOffer', + 'mapping' => 'getMapping' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer', $data ?? [], null); + $this->setIfExists('mapping', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer'] === null) { + $invalidProperties[] = "'offer' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer + * + * @return \OpenAPI\Client\Model\UpdateOfferDTO + */ + public function getOffer() + { + return $this->container['offer']; + } + + /** + * Sets offer + * + * @param \OpenAPI\Client\Model\UpdateOfferDTO $offer offer + * + * @return self + */ + public function setOffer($offer) + { + if (is_null($offer)) { + throw new \InvalidArgumentException('non-nullable offer cannot be null'); + } + $this->container['offer'] = $offer; + + return $this; + } + + /** + * Gets mapping + * + * @return \OpenAPI\Client\Model\UpdateMappingDTO|null + */ + public function getMapping() + { + return $this->container['mapping']; + } + + /** + * Sets mapping + * + * @param \OpenAPI\Client\Model\UpdateMappingDTO|null $mapping mapping + * + * @return self + */ + public function setMapping($mapping) + { + if (is_null($mapping)) { + throw new \InvalidArgumentException('non-nullable mapping cannot be null'); + } + $this->container['mapping'] = $mapping; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferMappingEntryDTO.php b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingEntryDTO.php new file mode 100644 index 00000000..06160eb4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingEntryDTO.php @@ -0,0 +1,512 @@ + + */ +class UpdateOfferMappingEntryDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferMappingEntryDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'mapping' => '\OpenAPI\Client\Model\OfferMappingDTO', + 'awaiting_moderation_mapping' => '\OpenAPI\Client\Model\OfferMappingDTO', + 'rejected_mapping' => '\OpenAPI\Client\Model\OfferMappingDTO', + 'offer' => '\OpenAPI\Client\Model\UpdateMappingsOfferDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'mapping' => null, + 'awaiting_moderation_mapping' => null, + 'rejected_mapping' => null, + 'offer' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'mapping' => false, + 'awaiting_moderation_mapping' => false, + 'rejected_mapping' => false, + 'offer' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'mapping' => 'mapping', + 'awaiting_moderation_mapping' => 'awaitingModerationMapping', + 'rejected_mapping' => 'rejectedMapping', + 'offer' => 'offer' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'mapping' => 'setMapping', + 'awaiting_moderation_mapping' => 'setAwaitingModerationMapping', + 'rejected_mapping' => 'setRejectedMapping', + 'offer' => 'setOffer' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'mapping' => 'getMapping', + 'awaiting_moderation_mapping' => 'getAwaitingModerationMapping', + 'rejected_mapping' => 'getRejectedMapping', + 'offer' => 'getOffer' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('mapping', $data ?? [], null); + $this->setIfExists('awaiting_moderation_mapping', $data ?? [], null); + $this->setIfExists('rejected_mapping', $data ?? [], null); + $this->setIfExists('offer', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getMapping() + { + return $this->container['mapping']; + } + + /** + * Sets mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $mapping mapping + * + * @return self + */ + public function setMapping($mapping) + { + if (is_null($mapping)) { + throw new \InvalidArgumentException('non-nullable mapping cannot be null'); + } + $this->container['mapping'] = $mapping; + + return $this; + } + + /** + * Gets awaiting_moderation_mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getAwaitingModerationMapping() + { + return $this->container['awaiting_moderation_mapping']; + } + + /** + * Sets awaiting_moderation_mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $awaiting_moderation_mapping awaiting_moderation_mapping + * + * @return self + */ + public function setAwaitingModerationMapping($awaiting_moderation_mapping) + { + if (is_null($awaiting_moderation_mapping)) { + throw new \InvalidArgumentException('non-nullable awaiting_moderation_mapping cannot be null'); + } + $this->container['awaiting_moderation_mapping'] = $awaiting_moderation_mapping; + + return $this; + } + + /** + * Gets rejected_mapping + * + * @return \OpenAPI\Client\Model\OfferMappingDTO|null + */ + public function getRejectedMapping() + { + return $this->container['rejected_mapping']; + } + + /** + * Sets rejected_mapping + * + * @param \OpenAPI\Client\Model\OfferMappingDTO|null $rejected_mapping rejected_mapping + * + * @return self + */ + public function setRejectedMapping($rejected_mapping) + { + if (is_null($rejected_mapping)) { + throw new \InvalidArgumentException('non-nullable rejected_mapping cannot be null'); + } + $this->container['rejected_mapping'] = $rejected_mapping; + + return $this; + } + + /** + * Gets offer + * + * @return \OpenAPI\Client\Model\UpdateMappingsOfferDTO|null + */ + public function getOffer() + { + return $this->container['offer']; + } + + /** + * Sets offer + * + * @param \OpenAPI\Client\Model\UpdateMappingsOfferDTO|null $offer offer + * + * @return self + */ + public function setOffer($offer) + { + if (is_null($offer)) { + throw new \InvalidArgumentException('non-nullable offer cannot be null'); + } + $this->container['offer'] = $offer; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferMappingEntryRequest.php b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingEntryRequest.php new file mode 100644 index 00000000..090eb7d7 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingEntryRequest.php @@ -0,0 +1,428 @@ + + */ +class UpdateOfferMappingEntryRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferMappingEntryRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_mapping_entries' => '\OpenAPI\Client\Model\UpdateOfferMappingEntryDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_mapping_entries' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_mapping_entries' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_mapping_entries' => 'offerMappingEntries' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_mapping_entries' => 'setOfferMappingEntries' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_mapping_entries' => 'getOfferMappingEntries' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_mapping_entries', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_mapping_entries'] === null) { + $invalidProperties[] = "'offer_mapping_entries' can't be null"; + } + if ((count($this->container['offer_mapping_entries']) > 500)) { + $invalidProperties[] = "invalid value for 'offer_mapping_entries', number of items must be less than or equal to 500."; + } + + if ((count($this->container['offer_mapping_entries']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_mapping_entries', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_mapping_entries + * + * @return \OpenAPI\Client\Model\UpdateOfferMappingEntryDTO[] + */ + public function getOfferMappingEntries() + { + return $this->container['offer_mapping_entries']; + } + + /** + * Sets offer_mapping_entries + * + * @param \OpenAPI\Client\Model\UpdateOfferMappingEntryDTO[] $offer_mapping_entries Информация о товарах в каталоге. + * + * @return self + */ + public function setOfferMappingEntries($offer_mapping_entries) + { + if (is_null($offer_mapping_entries)) { + throw new \InvalidArgumentException('non-nullable offer_mapping_entries cannot be null'); + } + + if ((count($offer_mapping_entries) > 500)) { + throw new \InvalidArgumentException('invalid value for $offer_mapping_entries when calling UpdateOfferMappingEntryRequest., number of items must be less than or equal to 500.'); + } + if ((count($offer_mapping_entries) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_mapping_entries when calling UpdateOfferMappingEntryRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_mapping_entries'] = $offer_mapping_entries; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferMappingResultDTO.php b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingResultDTO.php new file mode 100644 index 00000000..030d9266 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingResultDTO.php @@ -0,0 +1,517 @@ + + */ +class UpdateOfferMappingResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferMappingResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'errors' => '\OpenAPI\Client\Model\OfferMappingErrorDTO[]', + 'warnings' => '\OpenAPI\Client\Model\OfferMappingErrorDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'errors' => null, + 'warnings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'errors' => true, + 'warnings' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'errors' => 'errors', + 'warnings' => 'warnings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'errors' => 'setErrors', + 'warnings' => 'setWarnings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'errors' => 'getErrors', + 'warnings' => 'getWarnings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('errors', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateOfferMappingResultDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdateOfferMappingResultDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling UpdateOfferMappingResultDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets errors + * + * @return \OpenAPI\Client\Model\OfferMappingErrorDTO[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \OpenAPI\Client\Model\OfferMappingErrorDTO[]|null $errors Ошибки — информация в каталоге не обновится. + * + * @return self + */ + public function setErrors($errors) + { + if (is_null($errors)) { + array_push($this->openAPINullablesSetToNull, 'errors'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('errors', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['errors'] = $errors; + + return $this; + } + + /** + * Gets warnings + * + * @return \OpenAPI\Client\Model\OfferMappingErrorDTO[]|null + */ + public function getWarnings() + { + return $this->container['warnings']; + } + + /** + * Sets warnings + * + * @param \OpenAPI\Client\Model\OfferMappingErrorDTO[]|null $warnings Предупреждения — информация в каталоге обновится. + * + * @return self + */ + public function setWarnings($warnings) + { + if (is_null($warnings)) { + array_push($this->openAPINullablesSetToNull, 'warnings'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('warnings', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['warnings'] = $warnings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferMappingsRequest.php b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingsRequest.php new file mode 100644 index 00000000..7085f416 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingsRequest.php @@ -0,0 +1,461 @@ + + */ +class UpdateOfferMappingsRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferMappingsRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_mappings' => '\OpenAPI\Client\Model\UpdateOfferMappingDTO[]', + 'only_partner_media_content' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_mappings' => null, + 'only_partner_media_content' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_mappings' => false, + 'only_partner_media_content' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_mappings' => 'offerMappings', + 'only_partner_media_content' => 'onlyPartnerMediaContent' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_mappings' => 'setOfferMappings', + 'only_partner_media_content' => 'setOnlyPartnerMediaContent' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_mappings' => 'getOfferMappings', + 'only_partner_media_content' => 'getOnlyPartnerMediaContent' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_mappings', $data ?? [], null); + $this->setIfExists('only_partner_media_content', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_mappings'] === null) { + $invalidProperties[] = "'offer_mappings' can't be null"; + } + if ((count($this->container['offer_mappings']) > 500)) { + $invalidProperties[] = "invalid value for 'offer_mappings', number of items must be less than or equal to 500."; + } + + if ((count($this->container['offer_mappings']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_mappings', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_mappings + * + * @return \OpenAPI\Client\Model\UpdateOfferMappingDTO[] + */ + public function getOfferMappings() + { + return $this->container['offer_mappings']; + } + + /** + * Sets offer_mappings + * + * @param \OpenAPI\Client\Model\UpdateOfferMappingDTO[] $offer_mappings Перечень товаров, которые нужно добавить или обновить. + * + * @return self + */ + public function setOfferMappings($offer_mappings) + { + if (is_null($offer_mappings)) { + throw new \InvalidArgumentException('non-nullable offer_mappings cannot be null'); + } + + if ((count($offer_mappings) > 500)) { + throw new \InvalidArgumentException('invalid value for $offer_mappings when calling UpdateOfferMappingsRequest., number of items must be less than or equal to 500.'); + } + if ((count($offer_mappings) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_mappings when calling UpdateOfferMappingsRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offer_mappings'] = $offer_mappings; + + return $this; + } + + /** + * Gets only_partner_media_content + * + * @return bool|null + */ + public function getOnlyPartnerMediaContent() + { + return $this->container['only_partner_media_content']; + } + + /** + * Sets only_partner_media_content + * + * @param bool|null $only_partner_media_content Будут использоваться только переданные вами изображения товаров. Значение по умолчанию — `false`. Если вы хотите заменить изображения, которые добавил Маркет, передайте значение `true`. + * + * @return self + */ + public function setOnlyPartnerMediaContent($only_partner_media_content) + { + if (is_null($only_partner_media_content)) { + throw new \InvalidArgumentException('non-nullable only_partner_media_content cannot be null'); + } + $this->container['only_partner_media_content'] = $only_partner_media_content; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOfferMappingsResponse.php b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingsResponse.php new file mode 100644 index 00000000..ee8f730b --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOfferMappingsResponse.php @@ -0,0 +1,451 @@ + + */ +class UpdateOfferMappingsResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOfferMappingsResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'results' => '\OpenAPI\Client\Model\UpdateOfferMappingResultDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'results' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'results' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'results' => 'results' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'results' => 'setResults' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'results' => 'getResults' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('results', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets results + * + * @return \OpenAPI\Client\Model\UpdateOfferMappingResultDTO[]|null + */ + public function getResults() + { + return $this->container['results']; + } + + /** + * Sets results + * + * @param \OpenAPI\Client\Model\UpdateOfferMappingResultDTO[]|null $results Ошибки и предупреждения, которые появились при обработке списка характеристик. Каждый элемент списка соответствует одному товару. Если ошибок и предупреждений нет, поле не передается. + * + * @return self + */ + public function setResults($results) + { + if (is_null($results)) { + array_push($this->openAPINullablesSetToNull, 'results'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('results', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['results'] = $results; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOrderItemRequest.php b/erp24/lib/yandex_market_api/Model/UpdateOrderItemRequest.php new file mode 100644 index 00000000..dccda1cc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOrderItemRequest.php @@ -0,0 +1,456 @@ + + */ +class UpdateOrderItemRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOrderItemRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'items' => '\OpenAPI\Client\Model\OrderItemModificationDTO[]', + 'reason' => '\OpenAPI\Client\Model\OrderItemsModificationRequestReasonType' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'items' => null, + 'reason' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'items' => false, + 'reason' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'items' => 'items', + 'reason' => 'reason' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'items' => 'setItems', + 'reason' => 'setReason' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'items' => 'getItems', + 'reason' => 'getReason' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('items', $data ?? [], null); + $this->setIfExists('reason', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + if ((count($this->container['items']) < 1)) { + $invalidProperties[] = "invalid value for 'items', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\OrderItemModificationDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\OrderItemModificationDTO[] $items Список товаров в заказе. Если магазин не передал информацию о товаре во входных данных, он будет удален из заказа. Обязательный параметр. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + + + if ((count($items) < 1)) { + throw new \InvalidArgumentException('invalid length for $items when calling UpdateOrderItemRequest., number of items must be greater than or equal to 1.'); + } + $this->container['items'] = $items; + + return $this; + } + + /** + * Gets reason + * + * @return \OpenAPI\Client\Model\OrderItemsModificationRequestReasonType|null + */ + public function getReason() + { + return $this->container['reason']; + } + + /** + * Sets reason + * + * @param \OpenAPI\Client\Model\OrderItemsModificationRequestReasonType|null $reason reason + * + * @return self + */ + public function setReason($reason) + { + if (is_null($reason)) { + throw new \InvalidArgumentException('non-nullable reason cannot be null'); + } + $this->container['reason'] = $reason; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOrderStatusDTO.php b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusDTO.php new file mode 100644 index 00000000..048ad990 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusDTO.php @@ -0,0 +1,546 @@ + + */ +class UpdateOrderStatusDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOrderStatusDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'status' => '\OpenAPI\Client\Model\OrderStatusType', + 'substatus' => '\OpenAPI\Client\Model\OrderSubstatusType', + 'update_status' => '\OpenAPI\Client\Model\OrderUpdateStatusType', + 'error_details' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'status' => null, + 'substatus' => null, + 'update_status' => null, + 'error_details' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'status' => false, + 'substatus' => false, + 'update_status' => false, + 'error_details' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'status' => 'status', + 'substatus' => 'substatus', + 'update_status' => 'updateStatus', + 'error_details' => 'errorDetails' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'status' => 'setStatus', + 'substatus' => 'setSubstatus', + 'update_status' => 'setUpdateStatus', + 'error_details' => 'setErrorDetails' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'status' => 'getStatus', + 'substatus' => 'getSubstatus', + 'update_status' => 'getUpdateStatus', + 'error_details' => 'getErrorDetails' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('substatus', $data ?? [], null); + $this->setIfExists('update_status', $data ?? [], null); + $this->setIfExists('error_details', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int|null $id Идентификатор заказа. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\OrderStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\OrderStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets substatus + * + * @return \OpenAPI\Client\Model\OrderSubstatusType|null + */ + public function getSubstatus() + { + return $this->container['substatus']; + } + + /** + * Sets substatus + * + * @param \OpenAPI\Client\Model\OrderSubstatusType|null $substatus substatus + * + * @return self + */ + public function setSubstatus($substatus) + { + if (is_null($substatus)) { + throw new \InvalidArgumentException('non-nullable substatus cannot be null'); + } + $this->container['substatus'] = $substatus; + + return $this; + } + + /** + * Gets update_status + * + * @return \OpenAPI\Client\Model\OrderUpdateStatusType|null + */ + public function getUpdateStatus() + { + return $this->container['update_status']; + } + + /** + * Sets update_status + * + * @param \OpenAPI\Client\Model\OrderUpdateStatusType|null $update_status update_status + * + * @return self + */ + public function setUpdateStatus($update_status) + { + if (is_null($update_status)) { + throw new \InvalidArgumentException('non-nullable update_status cannot be null'); + } + $this->container['update_status'] = $update_status; + + return $this; + } + + /** + * Gets error_details + * + * @return string|null + */ + public function getErrorDetails() + { + return $this->container['error_details']; + } + + /** + * Sets error_details + * + * @param string|null $error_details Ошибка при изменении статуса заказа. Содержит описание ошибки и идентификатор заказа. Возвращается, если параметр `updateStatus` принимает значение `ERROR`. + * + * @return self + */ + public function setErrorDetails($error_details) + { + if (is_null($error_details)) { + throw new \InvalidArgumentException('non-nullable error_details cannot be null'); + } + $this->container['error_details'] = $error_details; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOrderStatusRequest.php b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusRequest.php new file mode 100644 index 00000000..c373684d --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusRequest.php @@ -0,0 +1,412 @@ + + */ +class UpdateOrderStatusRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOrderStatusRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order' => '\OpenAPI\Client\Model\OrderStatusChangeDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order' => 'order' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order' => 'setOrder' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order' => 'getOrder' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['order'] === null) { + $invalidProperties[] = "'order' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order + * + * @return \OpenAPI\Client\Model\OrderStatusChangeDTO + */ + public function getOrder() + { + return $this->container['order']; + } + + /** + * Sets order + * + * @param \OpenAPI\Client\Model\OrderStatusChangeDTO $order order + * + * @return self + */ + public function setOrder($order) + { + if (is_null($order)) { + throw new \InvalidArgumentException('non-nullable order cannot be null'); + } + $this->container['order'] = $order; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOrderStatusResponse.php b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusResponse.php new file mode 100644 index 00000000..fda86be9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusResponse.php @@ -0,0 +1,410 @@ + + */ +class UpdateOrderStatusResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOrderStatusResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'order' => '\OpenAPI\Client\Model\OrderDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'order' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'order' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'order' => 'order' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'order' => 'setOrder' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'order' => 'getOrder' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('order', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets order + * + * @return \OpenAPI\Client\Model\OrderDTO|null + */ + public function getOrder() + { + return $this->container['order']; + } + + /** + * Sets order + * + * @param \OpenAPI\Client\Model\OrderDTO|null $order order + * + * @return self + */ + public function setOrder($order) + { + if (is_null($order)) { + throw new \InvalidArgumentException('non-nullable order cannot be null'); + } + $this->container['order'] = $order; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesDTO.php b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesDTO.php new file mode 100644 index 00000000..a5545222 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesDTO.php @@ -0,0 +1,413 @@ + + */ +class UpdateOrderStatusesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOrderStatusesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'orders' => '\OpenAPI\Client\Model\UpdateOrderStatusDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'orders' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'orders' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'orders' => 'orders' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'orders' => 'setOrders' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'orders' => 'getOrders' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('orders', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['orders'] === null) { + $invalidProperties[] = "'orders' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets orders + * + * @return \OpenAPI\Client\Model\UpdateOrderStatusDTO[] + */ + public function getOrders() + { + return $this->container['orders']; + } + + /** + * Sets orders + * + * @param \OpenAPI\Client\Model\UpdateOrderStatusDTO[] $orders Список с обновленными заказами. + * + * @return self + */ + public function setOrders($orders) + { + if (is_null($orders)) { + throw new \InvalidArgumentException('non-nullable orders cannot be null'); + } + $this->container['orders'] = $orders; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesRequest.php b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesRequest.php new file mode 100644 index 00000000..7d58909c --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesRequest.php @@ -0,0 +1,428 @@ + + */ +class UpdateOrderStatusesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOrderStatusesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'orders' => '\OpenAPI\Client\Model\OrderStateDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'orders' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'orders' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'orders' => 'orders' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'orders' => 'setOrders' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'orders' => 'getOrders' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('orders', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['orders'] === null) { + $invalidProperties[] = "'orders' can't be null"; + } + if ((count($this->container['orders']) > 30)) { + $invalidProperties[] = "invalid value for 'orders', number of items must be less than or equal to 30."; + } + + if ((count($this->container['orders']) < 1)) { + $invalidProperties[] = "invalid value for 'orders', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets orders + * + * @return \OpenAPI\Client\Model\OrderStateDTO[] + */ + public function getOrders() + { + return $this->container['orders']; + } + + /** + * Sets orders + * + * @param \OpenAPI\Client\Model\OrderStateDTO[] $orders Список заказов. + * + * @return self + */ + public function setOrders($orders) + { + if (is_null($orders)) { + throw new \InvalidArgumentException('non-nullable orders cannot be null'); + } + + if ((count($orders) > 30)) { + throw new \InvalidArgumentException('invalid value for $orders when calling UpdateOrderStatusesRequest., number of items must be less than or equal to 30.'); + } + if ((count($orders) < 1)) { + throw new \InvalidArgumentException('invalid length for $orders when calling UpdateOrderStatusesRequest., number of items must be greater than or equal to 1.'); + } + $this->container['orders'] = $orders; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesResponse.php b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesResponse.php new file mode 100644 index 00000000..d705a1f1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOrderStatusesResponse.php @@ -0,0 +1,443 @@ + + */ +class UpdateOrderStatusesResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOrderStatusesResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\UpdateOrderStatusesDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\UpdateOrderStatusesDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\UpdateOrderStatusesDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOrderStorageLimitRequest.php b/erp24/lib/yandex_market_api/Model/UpdateOrderStorageLimitRequest.php new file mode 100644 index 00000000..05014880 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOrderStorageLimitRequest.php @@ -0,0 +1,413 @@ + + */ +class UpdateOrderStorageLimitRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOrderStorageLimitRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'new_date' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'new_date' => 'date' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'new_date' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'new_date' => 'newDate' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'new_date' => 'setNewDate' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'new_date' => 'getNewDate' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('new_date', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['new_date'] === null) { + $invalidProperties[] = "'new_date' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets new_date + * + * @return \DateTime + */ + public function getNewDate() + { + return $this->container['new_date']; + } + + /** + * Sets new_date + * + * @param \DateTime $new_date Новая дата, до которой заказ будет храниться в пункте выдачи. Срок хранения можно увеличить не больше, чем на 30 дней. Формат даты: `ГГГГ-ММ-ДД`. + * + * @return self + */ + public function setNewDate($new_date) + { + if (is_null($new_date)) { + throw new \InvalidArgumentException('non-nullable new_date cannot be null'); + } + $this->container['new_date'] = $new_date; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateOutletLicenseRequest.php b/erp24/lib/yandex_market_api/Model/UpdateOutletLicenseRequest.php new file mode 100644 index 00000000..d9b9e1a6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateOutletLicenseRequest.php @@ -0,0 +1,422 @@ + + */ +class UpdateOutletLicenseRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateOutletLicenseRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'licenses' => '\OpenAPI\Client\Model\OutletLicenseDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'licenses' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'licenses' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'licenses' => 'licenses' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'licenses' => 'setLicenses' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'licenses' => 'getLicenses' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('licenses', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['licenses'] === null) { + $invalidProperties[] = "'licenses' can't be null"; + } + if ((count($this->container['licenses']) < 1)) { + $invalidProperties[] = "invalid value for 'licenses', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets licenses + * + * @return \OpenAPI\Client\Model\OutletLicenseDTO[] + */ + public function getLicenses() + { + return $this->container['licenses']; + } + + /** + * Sets licenses + * + * @param \OpenAPI\Client\Model\OutletLicenseDTO[] $licenses Список лицензий. Обязательный параметр, должен содержать информацию хотя бы об одной лицензии. + * + * @return self + */ + public function setLicenses($licenses) + { + if (is_null($licenses)) { + throw new \InvalidArgumentException('non-nullable licenses cannot be null'); + } + + + if ((count($licenses) < 1)) { + throw new \InvalidArgumentException('invalid length for $licenses when calling UpdateOutletLicenseRequest., number of items must be greater than or equal to 1.'); + } + $this->container['licenses'] = $licenses; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdatePriceWithDiscountDTO.php b/erp24/lib/yandex_market_api/Model/UpdatePriceWithDiscountDTO.php new file mode 100644 index 00000000..9c421aa8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdatePriceWithDiscountDTO.php @@ -0,0 +1,502 @@ + + */ +class UpdatePriceWithDiscountDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdatePriceWithDiscountDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'value' => 'float', + 'currency_id' => '\OpenAPI\Client\Model\CurrencyType', + 'discount_base' => 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'value' => null, + 'currency_id' => null, + 'discount_base' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'value' => false, + 'currency_id' => false, + 'discount_base' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'value' => 'value', + 'currency_id' => 'currencyId', + 'discount_base' => 'discountBase' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'value' => 'setValue', + 'currency_id' => 'setCurrencyId', + 'discount_base' => 'setDiscountBase' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'value' => 'getValue', + 'currency_id' => 'getCurrencyId', + 'discount_base' => 'getDiscountBase' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('value', $data ?? [], null); + $this->setIfExists('currency_id', $data ?? [], null); + $this->setIfExists('discount_base', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['value'] === null) { + $invalidProperties[] = "'value' can't be null"; + } + if (($this->container['value'] <= 0)) { + $invalidProperties[] = "invalid value for 'value', must be bigger than 0."; + } + + if ($this->container['currency_id'] === null) { + $invalidProperties[] = "'currency_id' can't be null"; + } + if (!is_null($this->container['discount_base']) && ($this->container['discount_base'] <= 0)) { + $invalidProperties[] = "invalid value for 'discount_base', must be bigger than 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets value + * + * @return float + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param float $value Значение. + * + * @return self + */ + public function setValue($value) + { + if (is_null($value)) { + throw new \InvalidArgumentException('non-nullable value cannot be null'); + } + + if (($value <= 0)) { + throw new \InvalidArgumentException('invalid value for $value when calling UpdatePriceWithDiscountDTO., must be bigger than 0.'); + } + + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets currency_id + * + * @return \OpenAPI\Client\Model\CurrencyType + */ + public function getCurrencyId() + { + return $this->container['currency_id']; + } + + /** + * Sets currency_id + * + * @param \OpenAPI\Client\Model\CurrencyType $currency_id currency_id + * + * @return self + */ + public function setCurrencyId($currency_id) + { + if (is_null($currency_id)) { + throw new \InvalidArgumentException('non-nullable currency_id cannot be null'); + } + $this->container['currency_id'] = $currency_id; + + return $this; + } + + /** + * Gets discount_base + * + * @return float|null + */ + public function getDiscountBase() + { + return $this->container['discount_base']; + } + + /** + * Sets discount_base + * + * @param float|null $discount_base Цена до скидки. Число должно быть целым. Вы можете указать цену со скидкой от 5 до 99%. Передавайте этот параметр при каждом обновлении цены, если предоставляете скидку на товар. + * + * @return self + */ + public function setDiscountBase($discount_base) + { + if (is_null($discount_base)) { + throw new \InvalidArgumentException('non-nullable discount_base cannot be null'); + } + + if (($discount_base <= 0)) { + throw new \InvalidArgumentException('invalid value for $discount_base when calling UpdatePriceWithDiscountDTO., must be bigger than 0.'); + } + + $this->container['discount_base'] = $discount_base; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdatePricesRequest.php b/erp24/lib/yandex_market_api/Model/UpdatePricesRequest.php new file mode 100644 index 00000000..60534006 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdatePricesRequest.php @@ -0,0 +1,428 @@ + + */ +class UpdatePricesRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdatePricesRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offers' => '\OpenAPI\Client\Model\OfferPriceDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + if ((count($this->container['offers']) > 2000)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be less than or equal to 2000."; + } + + if ((count($this->container['offers']) < 1)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\OfferPriceDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\OfferPriceDTO[] $offers Список товаров. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + + if ((count($offers) > 2000)) { + throw new \InvalidArgumentException('invalid value for $offers when calling UpdatePricesRequest., number of items must be less than or equal to 2000.'); + } + if ((count($offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $offers when calling UpdatePricesRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdatePromoOfferDTO.php b/erp24/lib/yandex_market_api/Model/UpdatePromoOfferDTO.php new file mode 100644 index 00000000..11a3cced --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdatePromoOfferDTO.php @@ -0,0 +1,469 @@ + + */ +class UpdatePromoOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdatePromoOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'params' => '\OpenAPI\Client\Model\UpdatePromoOfferParamsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'params' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'params' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'params' => 'params' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'params' => 'setParams' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'params' => 'getParams' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('params', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdatePromoOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling UpdatePromoOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling UpdatePromoOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets params + * + * @return \OpenAPI\Client\Model\UpdatePromoOfferParamsDTO|null + */ + public function getParams() + { + return $this->container['params']; + } + + /** + * Sets params + * + * @param \OpenAPI\Client\Model\UpdatePromoOfferParamsDTO|null $params params + * + * @return self + */ + public function setParams($params) + { + if (is_null($params)) { + throw new \InvalidArgumentException('non-nullable params cannot be null'); + } + $this->container['params'] = $params; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdatePromoOfferDiscountParamsDTO.php b/erp24/lib/yandex_market_api/Model/UpdatePromoOfferDiscountParamsDTO.php new file mode 100644 index 00000000..c23bebf1 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdatePromoOfferDiscountParamsDTO.php @@ -0,0 +1,462 @@ + + */ +class UpdatePromoOfferDiscountParamsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdatePromoOfferDiscountParamsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'price' => 'int', + 'promo_price' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'price' => 'int64', + 'promo_price' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'price' => false, + 'promo_price' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'price' => 'price', + 'promo_price' => 'promoPrice' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'price' => 'setPrice', + 'promo_price' => 'setPromoPrice' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'price' => 'getPrice', + 'promo_price' => 'getPromoPrice' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('price', $data ?? [], null); + $this->setIfExists('promo_price', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['price']) && ($this->container['price'] < 1)) { + $invalidProperties[] = "invalid value for 'price', must be bigger than or equal to 1."; + } + + if (!is_null($this->container['promo_price']) && ($this->container['promo_price'] < 1)) { + $invalidProperties[] = "invalid value for 'promo_price', must be bigger than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets price + * + * @return int|null + */ + public function getPrice() + { + return $this->container['price']; + } + + /** + * Sets price + * + * @param int|null $price Зачеркнутая цена — та, по которой товар продавался до акции. Указывается в рублях. Число должно быть целым. + * + * @return self + */ + public function setPrice($price) + { + if (is_null($price)) { + throw new \InvalidArgumentException('non-nullable price cannot be null'); + } + + if (($price < 1)) { + throw new \InvalidArgumentException('invalid value for $price when calling UpdatePromoOfferDiscountParamsDTO., must be bigger than or equal to 1.'); + } + + $this->container['price'] = $price; + + return $this; + } + + /** + * Gets promo_price + * + * @return int|null + */ + public function getPromoPrice() + { + return $this->container['promo_price']; + } + + /** + * Sets promo_price + * + * @param int|null $promo_price Цена по акции — та, по которой вы хотите продавать товар. Указывается в рублях. Число должно быть целым. + * + * @return self + */ + public function setPromoPrice($promo_price) + { + if (is_null($promo_price)) { + throw new \InvalidArgumentException('non-nullable promo_price cannot be null'); + } + + if (($promo_price < 1)) { + throw new \InvalidArgumentException('invalid value for $promo_price when calling UpdatePromoOfferDiscountParamsDTO., must be bigger than or equal to 1.'); + } + + $this->container['promo_price'] = $promo_price; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdatePromoOfferParamsDTO.php b/erp24/lib/yandex_market_api/Model/UpdatePromoOfferParamsDTO.php new file mode 100644 index 00000000..db630ef0 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdatePromoOfferParamsDTO.php @@ -0,0 +1,410 @@ + + */ +class UpdatePromoOfferParamsDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdatePromoOfferParamsDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'discount_params' => '\OpenAPI\Client\Model\UpdatePromoOfferDiscountParamsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'discount_params' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'discount_params' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'discount_params' => 'discountParams' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'discount_params' => 'setDiscountParams' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'discount_params' => 'getDiscountParams' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('discount_params', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets discount_params + * + * @return \OpenAPI\Client\Model\UpdatePromoOfferDiscountParamsDTO|null + */ + public function getDiscountParams() + { + return $this->container['discount_params']; + } + + /** + * Sets discount_params + * + * @param \OpenAPI\Client\Model\UpdatePromoOfferDiscountParamsDTO|null $discount_params discount_params + * + * @return self + */ + public function setDiscountParams($discount_params) + { + if (is_null($discount_params)) { + throw new \InvalidArgumentException('non-nullable discount_params cannot be null'); + } + $this->container['discount_params'] = $discount_params; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdatePromoOffersRequest.php b/erp24/lib/yandex_market_api/Model/UpdatePromoOffersRequest.php new file mode 100644 index 00000000..256c4bf9 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdatePromoOffersRequest.php @@ -0,0 +1,465 @@ + + */ +class UpdatePromoOffersRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdatePromoOffersRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'promo_id' => 'string', + 'offers' => '\OpenAPI\Client\Model\UpdatePromoOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'promo_id' => null, + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'promo_id' => false, + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'promo_id' => 'promoId', + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'promo_id' => 'setPromoId', + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'promo_id' => 'getPromoId', + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('promo_id', $data ?? [], null); + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['promo_id'] === null) { + $invalidProperties[] = "'promo_id' can't be null"; + } + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + if ((count($this->container['offers']) > 500)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be less than or equal to 500."; + } + + if ((count($this->container['offers']) < 1)) { + $invalidProperties[] = "invalid value for 'offers', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets promo_id + * + * @return string + */ + public function getPromoId() + { + return $this->container['promo_id']; + } + + /** + * Sets promo_id + * + * @param string $promo_id Идентификатор акции. + * + * @return self + */ + public function setPromoId($promo_id) + { + if (is_null($promo_id)) { + throw new \InvalidArgumentException('non-nullable promo_id cannot be null'); + } + $this->container['promo_id'] = $promo_id; + + return $this; + } + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\UpdatePromoOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\UpdatePromoOfferDTO[] $offers Товары, которые необходимо добавить в акцию или цены которых нужно изменить. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + + if ((count($offers) > 500)) { + throw new \InvalidArgumentException('invalid value for $offers when calling UpdatePromoOffersRequest., number of items must be less than or equal to 500.'); + } + if ((count($offers) < 1)) { + throw new \InvalidArgumentException('invalid length for $offers when calling UpdatePromoOffersRequest., number of items must be greater than or equal to 1.'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdatePromoOffersResponse.php b/erp24/lib/yandex_market_api/Model/UpdatePromoOffersResponse.php new file mode 100644 index 00000000..05071aab --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdatePromoOffersResponse.php @@ -0,0 +1,444 @@ + + */ +class UpdatePromoOffersResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdatePromoOffersResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\UpdatePromoOffersResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\UpdatePromoOffersResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\UpdatePromoOffersResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdatePromoOffersResultDTO.php b/erp24/lib/yandex_market_api/Model/UpdatePromoOffersResultDTO.php new file mode 100644 index 00000000..61fce652 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdatePromoOffersResultDTO.php @@ -0,0 +1,458 @@ + + */ +class UpdatePromoOffersResultDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdatePromoOffersResultDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'rejected_offers' => '\OpenAPI\Client\Model\RejectedPromoOfferUpdateDTO[]', + 'warning_offers' => '\OpenAPI\Client\Model\WarningPromoOfferUpdateDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'rejected_offers' => null, + 'warning_offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'rejected_offers' => true, + 'warning_offers' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'rejected_offers' => 'rejectedOffers', + 'warning_offers' => 'warningOffers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'rejected_offers' => 'setRejectedOffers', + 'warning_offers' => 'setWarningOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'rejected_offers' => 'getRejectedOffers', + 'warning_offers' => 'getWarningOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('rejected_offers', $data ?? [], null); + $this->setIfExists('warning_offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets rejected_offers + * + * @return \OpenAPI\Client\Model\RejectedPromoOfferUpdateDTO[]|null + */ + public function getRejectedOffers() + { + return $this->container['rejected_offers']; + } + + /** + * Sets rejected_offers + * + * @param \OpenAPI\Client\Model\RejectedPromoOfferUpdateDTO[]|null $rejected_offers Изменения, которые были отклонены. Возвращается, только если есть отклоненные изменения. + * + * @return self + */ + public function setRejectedOffers($rejected_offers) + { + if (is_null($rejected_offers)) { + array_push($this->openAPINullablesSetToNull, 'rejected_offers'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('rejected_offers', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['rejected_offers'] = $rejected_offers; + + return $this; + } + + /** + * Gets warning_offers + * + * @return \OpenAPI\Client\Model\WarningPromoOfferUpdateDTO[]|null + */ + public function getWarningOffers() + { + return $this->container['warning_offers']; + } + + /** + * Sets warning_offers + * + * @param \OpenAPI\Client\Model\WarningPromoOfferUpdateDTO[]|null $warning_offers Изменения, по которым есть предупреждения. Они информируют о возможных проблемах. Информация о товарах обновится. Возвращается, только если есть предупреждения. + * + * @return self + */ + public function setWarningOffers($warning_offers) + { + if (is_null($warning_offers)) { + array_push($this->openAPINullablesSetToNull, 'warning_offers'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('warning_offers', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['warning_offers'] = $warning_offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateStockDTO.php b/erp24/lib/yandex_market_api/Model/UpdateStockDTO.php new file mode 100644 index 00000000..7e11c7cc --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateStockDTO.php @@ -0,0 +1,487 @@ + + */ +class UpdateStockDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateStockDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'sku' => 'string', + 'items' => '\OpenAPI\Client\Model\UpdateStockItemDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'sku' => null, + 'items' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'sku' => false, + 'items' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'sku' => 'sku', + 'items' => 'items' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'sku' => 'setSku', + 'items' => 'setItems' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'sku' => 'getSku', + 'items' => 'getItems' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('sku', $data ?? [], null); + $this->setIfExists('items', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['sku'] === null) { + $invalidProperties[] = "'sku' can't be null"; + } + if ((mb_strlen($this->container['sku']) > 255)) { + $invalidProperties[] = "invalid value for 'sku', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['sku']) < 1)) { + $invalidProperties[] = "invalid value for 'sku', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['sku'])) { + $invalidProperties[] = "invalid value for 'sku', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['items'] === null) { + $invalidProperties[] = "'items' can't be null"; + } + if ((count($this->container['items']) > 1)) { + $invalidProperties[] = "invalid value for 'items', number of items must be less than or equal to 1."; + } + + if ((count($this->container['items']) < 1)) { + $invalidProperties[] = "invalid value for 'items', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets sku + * + * @return string + */ + public function getSku() + { + return $this->container['sku']; + } + + /** + * Sets sku + * + * @param string $sku Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setSku($sku) + { + if (is_null($sku)) { + throw new \InvalidArgumentException('non-nullable sku cannot be null'); + } + if ((mb_strlen($sku) > 255)) { + throw new \InvalidArgumentException('invalid length for $sku when calling UpdateStockDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($sku) < 1)) { + throw new \InvalidArgumentException('invalid length for $sku when calling UpdateStockDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($sku)))) { + throw new \InvalidArgumentException("invalid value for \$sku when calling UpdateStockDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['sku'] = $sku; + + return $this; + } + + /** + * Gets items + * + * @return \OpenAPI\Client\Model\UpdateStockItemDTO[] + */ + public function getItems() + { + return $this->container['items']; + } + + /** + * Sets items + * + * @param \OpenAPI\Client\Model\UpdateStockItemDTO[] $items Информация об остатках товара. + * + * @return self + */ + public function setItems($items) + { + if (is_null($items)) { + throw new \InvalidArgumentException('non-nullable items cannot be null'); + } + + if ((count($items) > 1)) { + throw new \InvalidArgumentException('invalid value for $items when calling UpdateStockDTO., number of items must be less than or equal to 1.'); + } + if ((count($items) < 1)) { + throw new \InvalidArgumentException('invalid length for $items when calling UpdateStockDTO., number of items must be greater than or equal to 1.'); + } + $this->container['items'] = $items; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateStockItemDTO.php b/erp24/lib/yandex_market_api/Model/UpdateStockItemDTO.php new file mode 100644 index 00000000..bb2424b8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateStockItemDTO.php @@ -0,0 +1,463 @@ + + */ +class UpdateStockItemDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateStockItemDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'count' => 'int', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'count' => 'int64', + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'count' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'count' => 'count', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'count' => 'setCount', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'count' => 'getCount', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('count', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['count'] === null) { + $invalidProperties[] = "'count' can't be null"; + } + if (($this->container['count'] > 2000000000)) { + $invalidProperties[] = "invalid value for 'count', must be smaller than or equal to 2000000000."; + } + + if (($this->container['count'] < 0)) { + $invalidProperties[] = "invalid value for 'count', must be bigger than or equal to 0."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets count + * + * @return int + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param int $count Количество доступного товара. + * + * @return self + */ + public function setCount($count) + { + if (is_null($count)) { + throw new \InvalidArgumentException('non-nullable count cannot be null'); + } + + if (($count > 2000000000)) { + throw new \InvalidArgumentException('invalid value for $count when calling UpdateStockItemDTO., must be smaller than or equal to 2000000000.'); + } + if (($count < 0)) { + throw new \InvalidArgumentException('invalid value for $count when calling UpdateStockItemDTO., must be bigger than or equal to 0.'); + } + + $this->container['count'] = $count; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at Дата и время последнего обновления информации об остатках.

                                                                  Если вы не передали параметр `updatedAt`, используется текущее время.

                                                                  Формат даты и времени: ISO 8601 со смещением относительно UTC. Например, `2017-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateStocksRequest.php b/erp24/lib/yandex_market_api/Model/UpdateStocksRequest.php new file mode 100644 index 00000000..9474a5d8 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateStocksRequest.php @@ -0,0 +1,428 @@ + + */ +class UpdateStocksRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateStocksRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'skus' => '\OpenAPI\Client\Model\UpdateStockDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'skus' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'skus' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'skus' => 'skus' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'skus' => 'setSkus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'skus' => 'getSkus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('skus', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['skus'] === null) { + $invalidProperties[] = "'skus' can't be null"; + } + if ((count($this->container['skus']) > 2000)) { + $invalidProperties[] = "invalid value for 'skus', number of items must be less than or equal to 2000."; + } + + if ((count($this->container['skus']) < 1)) { + $invalidProperties[] = "invalid value for 'skus', number of items must be greater than or equal to 1."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets skus + * + * @return \OpenAPI\Client\Model\UpdateStockDTO[] + */ + public function getSkus() + { + return $this->container['skus']; + } + + /** + * Sets skus + * + * @param \OpenAPI\Client\Model\UpdateStockDTO[] $skus Данные об остатках товаров. + * + * @return self + */ + public function setSkus($skus) + { + if (is_null($skus)) { + throw new \InvalidArgumentException('non-nullable skus cannot be null'); + } + + if ((count($skus) > 2000)) { + throw new \InvalidArgumentException('invalid value for $skus when calling UpdateStocksRequest., number of items must be less than or equal to 2000.'); + } + if ((count($skus) < 1)) { + throw new \InvalidArgumentException('invalid length for $skus when calling UpdateStocksRequest., number of items must be greater than or equal to 1.'); + } + $this->container['skus'] = $skus; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/UpdateTimeDTO.php b/erp24/lib/yandex_market_api/Model/UpdateTimeDTO.php new file mode 100644 index 00000000..805b9fcd --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/UpdateTimeDTO.php @@ -0,0 +1,413 @@ + + */ +class UpdateTimeDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'UpdateTimeDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['updated_at'] === null) { + $invalidProperties[] = "'updated_at' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets updated_at + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime $updated_at Время последнего обновления. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/ValueRestrictionDTO.php b/erp24/lib/yandex_market_api/Model/ValueRestrictionDTO.php new file mode 100644 index 00000000..9a2c7992 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/ValueRestrictionDTO.php @@ -0,0 +1,459 @@ + + */ +class ValueRestrictionDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ValueRestrictionDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'limiting_parameter_id' => 'int', + 'limited_values' => '\OpenAPI\Client\Model\OptionValuesLimitedDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'limiting_parameter_id' => 'int64', + 'limited_values' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'limiting_parameter_id' => false, + 'limited_values' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'limiting_parameter_id' => 'limitingParameterId', + 'limited_values' => 'limitedValues' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'limiting_parameter_id' => 'setLimitingParameterId', + 'limited_values' => 'setLimitedValues' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'limiting_parameter_id' => 'getLimitingParameterId', + 'limited_values' => 'getLimitedValues' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('limiting_parameter_id', $data ?? [], null); + $this->setIfExists('limited_values', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['limiting_parameter_id'] === null) { + $invalidProperties[] = "'limiting_parameter_id' can't be null"; + } + if (($this->container['limiting_parameter_id'] < 1)) { + $invalidProperties[] = "invalid value for 'limiting_parameter_id', must be bigger than or equal to 1."; + } + + if ($this->container['limited_values'] === null) { + $invalidProperties[] = "'limited_values' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets limiting_parameter_id + * + * @return int + */ + public function getLimitingParameterId() + { + return $this->container['limiting_parameter_id']; + } + + /** + * Sets limiting_parameter_id + * + * @param int $limiting_parameter_id Идентификатор ограничивающей характеристики. + * + * @return self + */ + public function setLimitingParameterId($limiting_parameter_id) + { + if (is_null($limiting_parameter_id)) { + throw new \InvalidArgumentException('non-nullable limiting_parameter_id cannot be null'); + } + + if (($limiting_parameter_id < 1)) { + throw new \InvalidArgumentException('invalid value for $limiting_parameter_id when calling ValueRestrictionDTO., must be bigger than or equal to 1.'); + } + + $this->container['limiting_parameter_id'] = $limiting_parameter_id; + + return $this; + } + + /** + * Gets limited_values + * + * @return \OpenAPI\Client\Model\OptionValuesLimitedDTO[] + */ + public function getLimitedValues() + { + return $this->container['limited_values']; + } + + /** + * Sets limited_values + * + * @param \OpenAPI\Client\Model\OptionValuesLimitedDTO[] $limited_values Значения ограничивающей характеристики и соответствующие допустимые значения текущей характеристики. + * + * @return self + */ + public function setLimitedValues($limited_values) + { + if (is_null($limited_values)) { + throw new \InvalidArgumentException('non-nullable limited_values cannot be null'); + } + $this->container['limited_values'] = $limited_values; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/VerifyOrderEacRequest.php b/erp24/lib/yandex_market_api/Model/VerifyOrderEacRequest.php new file mode 100644 index 00000000..29644b18 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/VerifyOrderEacRequest.php @@ -0,0 +1,409 @@ + + */ +class VerifyOrderEacRequest implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'VerifyOrderEacRequest'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'code' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'code' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'code' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'code' => 'code' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'code' => 'setCode' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'code' => 'getCode' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('code', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets code + * + * @return string|null + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param string|null $code Код для подтверждения ЭАПП. + * + * @return self + */ + public function setCode($code) + { + if (is_null($code)) { + throw new \InvalidArgumentException('non-nullable code cannot be null'); + } + $this->container['code'] = $code; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/VerifyOrderEacResponse.php b/erp24/lib/yandex_market_api/Model/VerifyOrderEacResponse.php new file mode 100644 index 00000000..9a09ee58 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/VerifyOrderEacResponse.php @@ -0,0 +1,443 @@ + + */ +class VerifyOrderEacResponse implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'VerifyOrderEacResponse'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'status' => '\OpenAPI\Client\Model\ApiResponseStatusType', + 'result' => '\OpenAPI\Client\Model\EacVerificationResultDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'status' => null, + 'result' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'status' => false, + 'result' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'status' => 'status', + 'result' => 'result' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'result' => 'setResult' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'result' => 'getResult' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('result', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets status + * + * @return \OpenAPI\Client\Model\ApiResponseStatusType|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param \OpenAPI\Client\Model\ApiResponseStatusType|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets result + * + * @return \OpenAPI\Client\Model\EacVerificationResultDTO|null + */ + public function getResult() + { + return $this->container['result']; + } + + /** + * Sets result + * + * @param \OpenAPI\Client\Model\EacVerificationResultDTO|null $result result + * + * @return self + */ + public function setResult($result) + { + if (is_null($result)) { + throw new \InvalidArgumentException('non-nullable result cannot be null'); + } + $this->container['result'] = $result; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/WarehouseAddressDTO.php b/erp24/lib/yandex_market_api/Model/WarehouseAddressDTO.php new file mode 100644 index 00000000..d337f89e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/WarehouseAddressDTO.php @@ -0,0 +1,626 @@ + + */ +class WarehouseAddressDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'WarehouseAddressDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'city' => 'string', + 'street' => 'string', + 'number' => 'string', + 'building' => 'string', + 'block' => 'string', + 'gps' => '\OpenAPI\Client\Model\GpsDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'city' => null, + 'street' => null, + 'number' => null, + 'building' => null, + 'block' => null, + 'gps' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'city' => false, + 'street' => false, + 'number' => false, + 'building' => false, + 'block' => false, + 'gps' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'city' => 'city', + 'street' => 'street', + 'number' => 'number', + 'building' => 'building', + 'block' => 'block', + 'gps' => 'gps' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'city' => 'setCity', + 'street' => 'setStreet', + 'number' => 'setNumber', + 'building' => 'setBuilding', + 'block' => 'setBlock', + 'gps' => 'setGps' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'city' => 'getCity', + 'street' => 'getStreet', + 'number' => 'getNumber', + 'building' => 'getBuilding', + 'block' => 'getBlock', + 'gps' => 'getGps' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('city', $data ?? [], null); + $this->setIfExists('street', $data ?? [], null); + $this->setIfExists('number', $data ?? [], null); + $this->setIfExists('building', $data ?? [], null); + $this->setIfExists('block', $data ?? [], null); + $this->setIfExists('gps', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['city'] === null) { + $invalidProperties[] = "'city' can't be null"; + } + if ((mb_strlen($this->container['city']) > 200)) { + $invalidProperties[] = "invalid value for 'city', the character length must be smaller than or equal to 200."; + } + + if (!is_null($this->container['street']) && (mb_strlen($this->container['street']) > 512)) { + $invalidProperties[] = "invalid value for 'street', the character length must be smaller than or equal to 512."; + } + + if (!is_null($this->container['number']) && (mb_strlen($this->container['number']) > 256)) { + $invalidProperties[] = "invalid value for 'number', the character length must be smaller than or equal to 256."; + } + + if (!is_null($this->container['building']) && (mb_strlen($this->container['building']) > 16)) { + $invalidProperties[] = "invalid value for 'building', the character length must be smaller than or equal to 16."; + } + + if (!is_null($this->container['block']) && (mb_strlen($this->container['block']) > 16)) { + $invalidProperties[] = "invalid value for 'block', the character length must be smaller than or equal to 16."; + } + + if ($this->container['gps'] === null) { + $invalidProperties[] = "'gps' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets city + * + * @return string + */ + public function getCity() + { + return $this->container['city']; + } + + /** + * Sets city + * + * @param string $city Город. + * + * @return self + */ + public function setCity($city) + { + if (is_null($city)) { + throw new \InvalidArgumentException('non-nullable city cannot be null'); + } + if ((mb_strlen($city) > 200)) { + throw new \InvalidArgumentException('invalid length for $city when calling WarehouseAddressDTO., must be smaller than or equal to 200.'); + } + + $this->container['city'] = $city; + + return $this; + } + + /** + * Gets street + * + * @return string|null + */ + public function getStreet() + { + return $this->container['street']; + } + + /** + * Sets street + * + * @param string|null $street Улица. + * + * @return self + */ + public function setStreet($street) + { + if (is_null($street)) { + throw new \InvalidArgumentException('non-nullable street cannot be null'); + } + if ((mb_strlen($street) > 512)) { + throw new \InvalidArgumentException('invalid length for $street when calling WarehouseAddressDTO., must be smaller than or equal to 512.'); + } + + $this->container['street'] = $street; + + return $this; + } + + /** + * Gets number + * + * @return string|null + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param string|null $number Номер дома. + * + * @return self + */ + public function setNumber($number) + { + if (is_null($number)) { + throw new \InvalidArgumentException('non-nullable number cannot be null'); + } + if ((mb_strlen($number) > 256)) { + throw new \InvalidArgumentException('invalid length for $number when calling WarehouseAddressDTO., must be smaller than or equal to 256.'); + } + + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets building + * + * @return string|null + */ + public function getBuilding() + { + return $this->container['building']; + } + + /** + * Sets building + * + * @param string|null $building Номер строения. + * + * @return self + */ + public function setBuilding($building) + { + if (is_null($building)) { + throw new \InvalidArgumentException('non-nullable building cannot be null'); + } + if ((mb_strlen($building) > 16)) { + throw new \InvalidArgumentException('invalid length for $building when calling WarehouseAddressDTO., must be smaller than or equal to 16.'); + } + + $this->container['building'] = $building; + + return $this; + } + + /** + * Gets block + * + * @return string|null + */ + public function getBlock() + { + return $this->container['block']; + } + + /** + * Sets block + * + * @param string|null $block Номер корпуса. + * + * @return self + */ + public function setBlock($block) + { + if (is_null($block)) { + throw new \InvalidArgumentException('non-nullable block cannot be null'); + } + if ((mb_strlen($block) > 16)) { + throw new \InvalidArgumentException('invalid length for $block when calling WarehouseAddressDTO., must be smaller than or equal to 16.'); + } + + $this->container['block'] = $block; + + return $this; + } + + /** + * Gets gps + * + * @return \OpenAPI\Client\Model\GpsDTO + */ + public function getGps() + { + return $this->container['gps']; + } + + /** + * Sets gps + * + * @param \OpenAPI\Client\Model\GpsDTO $gps gps + * + * @return self + */ + public function setGps($gps) + { + if (is_null($gps)) { + throw new \InvalidArgumentException('non-nullable gps cannot be null'); + } + $this->container['gps'] = $gps; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/WarehouseDTO.php b/erp24/lib/yandex_market_api/Model/WarehouseDTO.php new file mode 100644 index 00000000..1d18a4fe --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/WarehouseDTO.php @@ -0,0 +1,558 @@ + + */ +class WarehouseDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'WarehouseDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'id' => 'int', + 'name' => 'string', + 'campaign_id' => 'int', + 'express' => 'bool', + 'address' => '\OpenAPI\Client\Model\WarehouseAddressDTO' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null, + 'campaign_id' => 'int64', + 'express' => null, + 'address' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'id' => false, + 'name' => false, + 'campaign_id' => false, + 'express' => false, + 'address' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'campaign_id' => 'campaignId', + 'express' => 'express', + 'address' => 'address' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'campaign_id' => 'setCampaignId', + 'express' => 'setExpress', + 'address' => 'setAddress' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'campaign_id' => 'getCampaignId', + 'express' => 'getExpress', + 'address' => 'getAddress' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('id', $data ?? [], null); + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('campaign_id', $data ?? [], null); + $this->setIfExists('express', $data ?? [], null); + $this->setIfExists('address', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['campaign_id'] === null) { + $invalidProperties[] = "'campaign_id' can't be null"; + } + if ($this->container['express'] === null) { + $invalidProperties[] = "'express' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return int + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id Идентификатор склада. + * + * @return self + */ + public function setId($id) + { + if (is_null($id)) { + throw new \InvalidArgumentException('non-nullable id cannot be null'); + } + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название склада. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets campaign_id + * + * @return int + */ + public function getCampaignId() + { + return $this->container['campaign_id']; + } + + /** + * Sets campaign_id + * + * @param int $campaign_id Идентификатор кампании в API и идентификатор магазина. + * + * @return self + */ + public function setCampaignId($campaign_id) + { + if (is_null($campaign_id)) { + throw new \InvalidArgumentException('non-nullable campaign_id cannot be null'); + } + $this->container['campaign_id'] = $campaign_id; + + return $this; + } + + /** + * Gets express + * + * @return bool + */ + public function getExpress() + { + return $this->container['express']; + } + + /** + * Sets express + * + * @param bool $express Возможна ли доставка по модели Экспресс. + * + * @return self + */ + public function setExpress($express) + { + if (is_null($express)) { + throw new \InvalidArgumentException('non-nullable express cannot be null'); + } + $this->container['express'] = $express; + + return $this; + } + + /** + * Gets address + * + * @return \OpenAPI\Client\Model\WarehouseAddressDTO|null + */ + public function getAddress() + { + return $this->container['address']; + } + + /** + * Sets address + * + * @param \OpenAPI\Client\Model\WarehouseAddressDTO|null $address address + * + * @return self + */ + public function setAddress($address) + { + if (is_null($address)) { + throw new \InvalidArgumentException('non-nullable address cannot be null'); + } + $this->container['address'] = $address; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/WarehouseGroupDTO.php b/erp24/lib/yandex_market_api/Model/WarehouseGroupDTO.php new file mode 100644 index 00000000..2db7a3c4 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/WarehouseGroupDTO.php @@ -0,0 +1,487 @@ + + */ +class WarehouseGroupDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'WarehouseGroupDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'name' => 'string', + 'main_warehouse' => '\OpenAPI\Client\Model\WarehouseDTO', + 'warehouses' => '\OpenAPI\Client\Model\WarehouseDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'name' => null, + 'main_warehouse' => null, + 'warehouses' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'name' => false, + 'main_warehouse' => false, + 'warehouses' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'main_warehouse' => 'mainWarehouse', + 'warehouses' => 'warehouses' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'main_warehouse' => 'setMainWarehouse', + 'warehouses' => 'setWarehouses' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'main_warehouse' => 'getMainWarehouse', + 'warehouses' => 'getWarehouses' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('name', $data ?? [], null); + $this->setIfExists('main_warehouse', $data ?? [], null); + $this->setIfExists('warehouses', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + if ($this->container['main_warehouse'] === null) { + $invalidProperties[] = "'main_warehouse' can't be null"; + } + if ($this->container['warehouses'] === null) { + $invalidProperties[] = "'warehouses' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name Название группы складов. + * + * @return self + */ + public function setName($name) + { + if (is_null($name)) { + throw new \InvalidArgumentException('non-nullable name cannot be null'); + } + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets main_warehouse + * + * @return \OpenAPI\Client\Model\WarehouseDTO + */ + public function getMainWarehouse() + { + return $this->container['main_warehouse']; + } + + /** + * Sets main_warehouse + * + * @param \OpenAPI\Client\Model\WarehouseDTO $main_warehouse main_warehouse + * + * @return self + */ + public function setMainWarehouse($main_warehouse) + { + if (is_null($main_warehouse)) { + throw new \InvalidArgumentException('non-nullable main_warehouse cannot be null'); + } + $this->container['main_warehouse'] = $main_warehouse; + + return $this; + } + + /** + * Gets warehouses + * + * @return \OpenAPI\Client\Model\WarehouseDTO[] + */ + public function getWarehouses() + { + return $this->container['warehouses']; + } + + /** + * Sets warehouses + * + * @param \OpenAPI\Client\Model\WarehouseDTO[] $warehouses Список складов, входящих в группу. + * + * @return self + */ + public function setWarehouses($warehouses) + { + if (is_null($warehouses)) { + throw new \InvalidArgumentException('non-nullable warehouses cannot be null'); + } + $this->container['warehouses'] = $warehouses; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/WarehouseOfferDTO.php b/erp24/lib/yandex_market_api/Model/WarehouseOfferDTO.php new file mode 100644 index 00000000..caaa46e6 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/WarehouseOfferDTO.php @@ -0,0 +1,540 @@ + + */ +class WarehouseOfferDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'WarehouseOfferDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'turnover_summary' => '\OpenAPI\Client\Model\TurnoverDTO', + 'stocks' => '\OpenAPI\Client\Model\WarehouseStockDTO[]', + 'updated_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'turnover_summary' => null, + 'stocks' => null, + 'updated_at' => 'date-time' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'turnover_summary' => false, + 'stocks' => false, + 'updated_at' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'turnover_summary' => 'turnoverSummary', + 'stocks' => 'stocks', + 'updated_at' => 'updatedAt' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'turnover_summary' => 'setTurnoverSummary', + 'stocks' => 'setStocks', + 'updated_at' => 'setUpdatedAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'turnover_summary' => 'getTurnoverSummary', + 'stocks' => 'getStocks', + 'updated_at' => 'getUpdatedAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('turnover_summary', $data ?? [], null); + $this->setIfExists('stocks', $data ?? [], null); + $this->setIfExists('updated_at', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['stocks'] === null) { + $invalidProperties[] = "'stocks' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling WarehouseOfferDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling WarehouseOfferDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling WarehouseOfferDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets turnover_summary + * + * @return \OpenAPI\Client\Model\TurnoverDTO|null + */ + public function getTurnoverSummary() + { + return $this->container['turnover_summary']; + } + + /** + * Sets turnover_summary + * + * @param \OpenAPI\Client\Model\TurnoverDTO|null $turnover_summary turnover_summary + * + * @return self + */ + public function setTurnoverSummary($turnover_summary) + { + if (is_null($turnover_summary)) { + throw new \InvalidArgumentException('non-nullable turnover_summary cannot be null'); + } + $this->container['turnover_summary'] = $turnover_summary; + + return $this; + } + + /** + * Gets stocks + * + * @return \OpenAPI\Client\Model\WarehouseStockDTO[] + */ + public function getStocks() + { + return $this->container['stocks']; + } + + /** + * Sets stocks + * + * @param \OpenAPI\Client\Model\WarehouseStockDTO[] $stocks Информация об остатках. + * + * @return self + */ + public function setStocks($stocks) + { + if (is_null($stocks)) { + throw new \InvalidArgumentException('non-nullable stocks cannot be null'); + } + $this->container['stocks'] = $stocks; + + return $this; + } + + /** + * Gets updated_at + * + * @return \DateTime|null + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param \DateTime|null $updated_at Дата и время последнего обновления информации об остатках. Формат даты и времени: ISO 8601 со смещением относительно UTC. Например, `2023-11-21T00:42:42+03:00`. + * + * @return self + */ + public function setUpdatedAt($updated_at) + { + if (is_null($updated_at)) { + throw new \InvalidArgumentException('non-nullable updated_at cannot be null'); + } + $this->container['updated_at'] = $updated_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/WarehouseOffersDTO.php b/erp24/lib/yandex_market_api/Model/WarehouseOffersDTO.php new file mode 100644 index 00000000..ca42ffa5 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/WarehouseOffersDTO.php @@ -0,0 +1,450 @@ + + */ +class WarehouseOffersDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'WarehouseOffersDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'warehouse_id' => 'int', + 'offers' => '\OpenAPI\Client\Model\WarehouseOfferDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'warehouse_id' => 'int64', + 'offers' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'warehouse_id' => false, + 'offers' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'warehouse_id' => 'warehouseId', + 'offers' => 'offers' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'warehouse_id' => 'setWarehouseId', + 'offers' => 'setOffers' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'warehouse_id' => 'getWarehouseId', + 'offers' => 'getOffers' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('warehouse_id', $data ?? [], null); + $this->setIfExists('offers', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['warehouse_id'] === null) { + $invalidProperties[] = "'warehouse_id' can't be null"; + } + if ($this->container['offers'] === null) { + $invalidProperties[] = "'offers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets warehouse_id + * + * @return int + */ + public function getWarehouseId() + { + return $this->container['warehouse_id']; + } + + /** + * Sets warehouse_id + * + * @param int $warehouse_id Идентификатор склада. + * + * @return self + */ + public function setWarehouseId($warehouse_id) + { + if (is_null($warehouse_id)) { + throw new \InvalidArgumentException('non-nullable warehouse_id cannot be null'); + } + $this->container['warehouse_id'] = $warehouse_id; + + return $this; + } + + /** + * Gets offers + * + * @return \OpenAPI\Client\Model\WarehouseOfferDTO[] + */ + public function getOffers() + { + return $this->container['offers']; + } + + /** + * Sets offers + * + * @param \OpenAPI\Client\Model\WarehouseOfferDTO[] $offers Информация об остатках. + * + * @return self + */ + public function setOffers($offers) + { + if (is_null($offers)) { + throw new \InvalidArgumentException('non-nullable offers cannot be null'); + } + $this->container['offers'] = $offers; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/WarehouseStockDTO.php b/erp24/lib/yandex_market_api/Model/WarehouseStockDTO.php new file mode 100644 index 00000000..8c0a155e --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/WarehouseStockDTO.php @@ -0,0 +1,450 @@ + + */ +class WarehouseStockDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'WarehouseStockDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => '\OpenAPI\Client\Model\WarehouseStockType', + 'count' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'count' => 'int64' + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'count' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'count' => 'count' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'count' => 'setCount' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'count' => 'getCount' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('count', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['type'] === null) { + $invalidProperties[] = "'type' can't be null"; + } + if ($this->container['count'] === null) { + $invalidProperties[] = "'count' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return \OpenAPI\Client\Model\WarehouseStockType + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param \OpenAPI\Client\Model\WarehouseStockType $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets count + * + * @return int + */ + public function getCount() + { + return $this->container['count']; + } + + /** + * Sets count + * + * @param int $count Значение остатков. + * + * @return self + */ + public function setCount($count) + { + if (is_null($count)) { + throw new \InvalidArgumentException('non-nullable count cannot be null'); + } + $this->container['count'] = $count; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/WarehouseStockType.php b/erp24/lib/yandex_market_api/Model/WarehouseStockType.php new file mode 100644 index 00000000..4dda8f73 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/WarehouseStockType.php @@ -0,0 +1,78 @@ + + */ +class WarehousesDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'WarehousesDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'warehouses' => '\OpenAPI\Client\Model\WarehouseDTO[]', + 'warehouse_groups' => '\OpenAPI\Client\Model\WarehouseGroupDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'warehouses' => null, + 'warehouse_groups' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'warehouses' => false, + 'warehouse_groups' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'warehouses' => 'warehouses', + 'warehouse_groups' => 'warehouseGroups' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'warehouses' => 'setWarehouses', + 'warehouse_groups' => 'setWarehouseGroups' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'warehouses' => 'getWarehouses', + 'warehouse_groups' => 'getWarehouseGroups' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('warehouses', $data ?? [], null); + $this->setIfExists('warehouse_groups', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['warehouses'] === null) { + $invalidProperties[] = "'warehouses' can't be null"; + } + if ($this->container['warehouse_groups'] === null) { + $invalidProperties[] = "'warehouse_groups' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets warehouses + * + * @return \OpenAPI\Client\Model\WarehouseDTO[] + */ + public function getWarehouses() + { + return $this->container['warehouses']; + } + + /** + * Sets warehouses + * + * @param \OpenAPI\Client\Model\WarehouseDTO[] $warehouses Список складов, не входящих в группы. + * + * @return self + */ + public function setWarehouses($warehouses) + { + if (is_null($warehouses)) { + throw new \InvalidArgumentException('non-nullable warehouses cannot be null'); + } + $this->container['warehouses'] = $warehouses; + + return $this; + } + + /** + * Gets warehouse_groups + * + * @return \OpenAPI\Client\Model\WarehouseGroupDTO[] + */ + public function getWarehouseGroups() + { + return $this->container['warehouse_groups']; + } + + /** + * Sets warehouse_groups + * + * @param \OpenAPI\Client\Model\WarehouseGroupDTO[] $warehouse_groups Список групп складов. + * + * @return self + */ + public function setWarehouseGroups($warehouse_groups) + { + if (is_null($warehouse_groups)) { + throw new \InvalidArgumentException('non-nullable warehouse_groups cannot be null'); + } + $this->container['warehouse_groups'] = $warehouse_groups; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/Model/WarningPromoOfferUpdateDTO.php b/erp24/lib/yandex_market_api/Model/WarningPromoOfferUpdateDTO.php new file mode 100644 index 00000000..2c9ce612 --- /dev/null +++ b/erp24/lib/yandex_market_api/Model/WarningPromoOfferUpdateDTO.php @@ -0,0 +1,472 @@ + + */ +class WarningPromoOfferUpdateDTO implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'WarningPromoOfferUpdateDTO'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'offer_id' => 'string', + 'warnings' => '\OpenAPI\Client\Model\PromoOfferUpdateWarningDTO[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'offer_id' => null, + 'warnings' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'offer_id' => false, + 'warnings' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'offer_id' => 'offerId', + 'warnings' => 'warnings' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'offer_id' => 'setOfferId', + 'warnings' => 'setWarnings' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'offer_id' => 'getOfferId', + 'warnings' => 'getWarnings' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('offer_id', $data ?? [], null); + $this->setIfExists('warnings', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['offer_id'] === null) { + $invalidProperties[] = "'offer_id' can't be null"; + } + if ((mb_strlen($this->container['offer_id']) > 255)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be smaller than or equal to 255."; + } + + if ((mb_strlen($this->container['offer_id']) < 1)) { + $invalidProperties[] = "invalid value for 'offer_id', the character length must be bigger than or equal to 1."; + } + + if (!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", $this->container['offer_id'])) { + $invalidProperties[] = "invalid value for 'offer_id', must be conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."; + } + + if ($this->container['warnings'] === null) { + $invalidProperties[] = "'warnings' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets offer_id + * + * @return string + */ + public function getOfferId() + { + return $this->container['offer_id']; + } + + /** + * Sets offer_id + * + * @param string $offer_id Ваш SKU — идентификатор товара в вашей системе. Правила использования SKU: * У каждого товара SKU должен быть свой. * SKU товара нельзя менять — можно только удалить товар и добавить заново с новым SKU. * Уже заданный SKU нельзя освободить и использовать заново для другого товара. Каждый товар должен получать новый идентификатор, до того никогда не использовавшийся в вашем каталоге. [Что такое SKU и как его назначать](https://yandex.ru/support/marketplace/assortment/add/index.html#fields) + * + * @return self + */ + public function setOfferId($offer_id) + { + if (is_null($offer_id)) { + throw new \InvalidArgumentException('non-nullable offer_id cannot be null'); + } + if ((mb_strlen($offer_id) > 255)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling WarningPromoOfferUpdateDTO., must be smaller than or equal to 255.'); + } + if ((mb_strlen($offer_id) < 1)) { + throw new \InvalidArgumentException('invalid length for $offer_id when calling WarningPromoOfferUpdateDTO., must be bigger than or equal to 1.'); + } + if ((!preg_match("/^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/", ObjectSerializer::toString($offer_id)))) { + throw new \InvalidArgumentException("invalid value for \$offer_id when calling WarningPromoOfferUpdateDTO., must conform to the pattern /^[^\\x00-\\x08\\x0A-\\x1f\\x7f]{1,255}$/."); + } + + $this->container['offer_id'] = $offer_id; + + return $this; + } + + /** + * Gets warnings + * + * @return \OpenAPI\Client\Model\PromoOfferUpdateWarningDTO[] + */ + public function getWarnings() + { + return $this->container['warnings']; + } + + /** + * Sets warnings + * + * @param \OpenAPI\Client\Model\PromoOfferUpdateWarningDTO[] $warnings Предупреждения, которые появились при добавлении товара в акцию или изменении его цен. + * + * @return self + */ + public function setWarnings($warnings) + { + if (is_null($warnings)) { + throw new \InvalidArgumentException('non-nullable warnings cannot be null'); + } + $this->container['warnings'] = $warnings; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/erp24/lib/yandex_market_api/ObjectSerializer.php b/erp24/lib/yandex_market_api/ObjectSerializer.php new file mode 100644 index 00000000..a605cde7 --- /dev/null +++ b/erp24/lib/yandex_market_api/ObjectSerializer.php @@ -0,0 +1,617 @@ +format('Y-m-d') : $data->format(self::$dateTimeFormat); + } + + if (is_array($data)) { + foreach ($data as $property => $value) { + $data[$property] = self::sanitizeForSerialization($value); + } + return $data; + } + + if (is_object($data)) { + $values = []; + if ($data instanceof ModelInterface) { + $formats = $data::openAPIFormats(); + foreach ($data::openAPITypes() as $property => $openAPIType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + $callable = [$openAPIType, 'getAllowableEnumValues']; + if (is_callable($callable)) { + /** array $callable */ + $allowedEnumTypes = $callable(); + if (!in_array($value, $allowedEnumTypes, true)) { + $imploded = implode("', '", $allowedEnumTypes); + throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); + } + } + } + if (($data::isNullable($property) && $data->isNullableSetToNull($property)) || $value !== null) { + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); + } + } + } else { + foreach($data as $property => $value) { + $values[$property] = self::sanitizeForSerialization($value); + } + } + return (object)$values; + } else { + return (string)$data; + } + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param string $filename filename to be sanitized + * + * @return string the sanitized filename + */ + public static function sanitizeFilename($filename) + { + if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { + return $match[1]; + } else { + return $filename; + } + } + + /** + * Shorter timestamp microseconds to 6 digits length. + * + * @param string $timestamp Original timestamp + * + * @return string the shorten timestamp + */ + public static function sanitizeTimestamp($timestamp) + { + if (!is_string($timestamp)) return $timestamp; + + return preg_replace('/(:\d{2}.\d{6})\d*/', '$1', $timestamp); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the path, by url-encoding. + * + * @param string $value a string which will be part of the path + * + * @return string the serialized object + */ + public static function toPathValue($value) + { + return rawurlencode(self::toString($value)); + } + + /** + * Checks if a value is empty, based on its OpenAPI type. + * + * @param mixed $value + * @param string $openApiType + * + * @return bool true if $value is empty + */ + private static function isEmptyValue($value, string $openApiType): bool + { + # If empty() returns false, it is not empty regardless of its type. + if (!empty($value)) { + return false; + } + + # Null is always empty, as we cannot send a real "null" value in a query parameter. + if ($value === null) { + return true; + } + + switch ($openApiType) { + # For numeric values, false and '' are considered empty. + # This comparison is safe for floating point values, since the previous call to empty() will + # filter out values that don't match 0. + case 'int': + case 'integer': + return $value !== 0; + + case 'number': + case 'float': + return $value !== 0 && $value !== 0.0; + + # For boolean values, '' is considered empty + case 'bool': + case 'boolean': + return !in_array($value, [false, 0], true); + + # For string values, '' is considered empty. + case 'string': + return $value === ''; + + # For all the other types, any value at this point can be considered empty. + default: + return true; + } + } + + /** + * Take query parameter properties and turn it into an array suitable for + * native http_build_query or GuzzleHttp\Psr7\Query::build. + * + * @param mixed $value Parameter value + * @param string $paramName Parameter name + * @param string $openApiType OpenAPIType eg. array or object + * @param string $style Parameter serialization style + * @param bool $explode Parameter explode option + * @param bool $required Whether query param is required or not + * + * @return array + */ + public static function toQueryValue( + $value, + string $paramName, + string $openApiType = 'string', + string $style = 'form', + bool $explode = true, + bool $required = true + ): array { + + # Check if we should omit this parameter from the query. This should only happen when: + # - Parameter is NOT required; AND + # - its value is set to a value that is equivalent to "empty", depending on its OpenAPI type. For + # example, 0 as "int" or "boolean" is NOT an empty value. + if (self::isEmptyValue($value, $openApiType)) { + if ($required) { + return ["{$paramName}" => '']; + } else { + return []; + } + } + + # Handle DateTime objects in query + if($openApiType === "\\DateTime" && $value instanceof \DateTime) { + return ["{$paramName}" => $value->format(self::$dateTimeFormat)]; + } + + $query = []; + $value = (in_array($openApiType, ['object', 'array'], true)) ? (array)$value : $value; + + // since \GuzzleHttp\Psr7\Query::build fails with nested arrays + // need to flatten array first + $flattenArray = function ($arr, $name, &$result = []) use (&$flattenArray, $style, $explode) { + if (!is_array($arr)) return $arr; + + foreach ($arr as $k => $v) { + $prop = ($style === 'deepObject') ? $prop = "{$name}[{$k}]" : $k; + + if (is_array($v)) { + $flattenArray($v, $prop, $result); + } else { + if ($style !== 'deepObject' && !$explode) { + // push key itself + $result[] = $prop; + } + $result[$prop] = $v; + } + } + return $result; + }; + + $value = $flattenArray($value, $paramName); + + // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values + if ($openApiType === 'array' && $style === 'deepObject' && $explode) { + return $value; + } + + if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) { + return $value; + } + + if ('boolean' === $openApiType && is_bool($value)) { + $value = self::convertBoolToQueryStringFormat($value); + } + + // handle style in serializeCollection + $query[$paramName] = ($explode) ? $value : self::serializeCollection((array)$value, $style); + + return $query; + } + + /** + * Convert boolean value to format for query string. + * + * @param bool $value Boolean value + * + * @return int|string Boolean value in format + */ + public static function convertBoolToQueryStringFormat(bool $value) + { + if (Configuration::BOOLEAN_FORMAT_STRING == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString()) { + return $value ? 'true' : 'false'; + } + + return (int) $value; + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the header. If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * + * @param string $value a string which will be part of the header + * + * @return string the header string + */ + public static function toHeaderValue($value) + { + $callable = [$value, 'toHeaderValue']; + if (is_callable($callable)) { + return $callable(); + } + + return self::toString($value); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the http body (form parameter). If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * + * @param string|\SplFileObject $value the value of the form parameter + * + * @return string the form string + */ + public static function toFormValue($value) + { + if ($value instanceof \SplFileObject) { + return $value->getRealPath(); + } else { + return self::toString($value); + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the parameter. If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * If it's a boolean, convert it to "true" or "false". + * + * @param float|int|bool|\DateTime $value the value of the parameter + * + * @return string the header string + */ + public static function toString($value) + { + if ($value instanceof \DateTime) { // datetime in ISO8601 format + return $value->format(self::$dateTimeFormat); + } elseif (is_bool($value)) { + return $value ? 'true' : 'false'; + } else { + return (string) $value; + } + } + + /** + * Serialize an array to a string. + * + * @param array $collection collection to serialize to a string + * @param string $style the format use for serialization (csv, + * ssv, tsv, pipes, multi) + * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array + * + * @return string + */ + public static function serializeCollection(array $collection, $style, $allowCollectionFormatMulti = false) + { + if ($allowCollectionFormatMulti && ('multi' === $style)) { + // http_build_query() almost does the job for us. We just + // need to fix the result of multidimensional arrays. + return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&')); + } + switch ($style) { + case 'pipeDelimited': + case 'pipes': + return implode('|', $collection); + + case 'tsv': + return implode("\t", $collection); + + case 'spaceDelimited': + case 'ssv': + return implode(' ', $collection); + + case 'simple': + case 'csv': + // Deliberate fall through. CSV is default format. + default: + return implode(',', $collection); + } + } + + /** + * Deserialize a JSON string into an object + * + * @param mixed $data object or primitive to be deserialized + * @param string $class class name is passed as a string + * @param string[] $httpHeaders HTTP headers + * + * @return object|array|null a single or an array of $class instances + */ + public static function deserialize($data, $class, $httpHeaders = null) + { + if (null === $data) { + return null; + } + + if (strcasecmp(substr($class, -2), '[]') === 0) { + $data = is_string($data) ? json_decode($data) : $data; + + if (!is_array($data)) { + throw new \InvalidArgumentException("Invalid array '$class'"); + } + + $subClass = substr($class, 0, -2); + $values = []; + foreach ($data as $key => $value) { + $values[] = self::deserialize($value, $subClass, null); + } + return $values; + } + + if (preg_match('/^(array<|map\[)/', $class)) { // for associative array e.g. array + $data = is_string($data) ? json_decode($data) : $data; + settype($data, 'array'); + $inner = substr($class, 4, -1); + $deserialized = []; + if (strrpos($inner, ",") !== false) { + $subClass_array = explode(',', $inner, 2); + $subClass = $subClass_array[1]; + foreach ($data as $key => $value) { + $deserialized[$key] = self::deserialize($value, $subClass, null); + } + } + return $deserialized; + } + + if ($class === 'object') { + settype($data, 'array'); + return $data; + } elseif ($class === 'mixed') { + settype($data, gettype($data)); + return $data; + } + + if ($class === '\DateTime') { + // Some APIs return an invalid, empty string as a + // date-time property. DateTime::__construct() will return + // the current time for empty input which is probably not + // what is meant. The invalid empty string is probably to + // be interpreted as a missing field/value. Let's handle + // this graceful. + if (!empty($data)) { + try { + return new \DateTime($data); + } catch (\Exception $exception) { + // Some APIs return a date-time with too high nanosecond + // precision for php's DateTime to handle. + // With provided regexp 6 digits of microseconds saved + return new \DateTime(self::sanitizeTimestamp($data)); + } + } else { + return null; + } + } + + if ($class === '\SplFileObject') { + $data = Utils::streamFor($data); + + /** @var \Psr\Http\Message\StreamInterface $data */ + + // determine file name + if ( + is_array($httpHeaders) + && array_key_exists('Content-Disposition', $httpHeaders) + && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match) + ) { + $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); + } else { + $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); + } + + $file = fopen($filename, 'w'); + while ($chunk = $data->read(200)) { + fwrite($file, $chunk); + } + fclose($file); + + return new \SplFileObject($filename, 'r'); + } + + /** @psalm-suppress ParadoxicalCondition */ + if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + settype($data, $class); + return $data; + } + + + if (method_exists($class, 'getAllowableEnumValues')) { + if (!in_array($data, $class::getAllowableEnumValues(), true)) { + $imploded = implode("', '", $class::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + } + return $data; + } else { + $data = is_string($data) ? json_decode($data) : $data; + + if (is_array($data)) { + $data = (object)$data; + } + + // If a discriminator is defined and points to a valid subclass, use it. + $discriminator = $class::DISCRIMINATOR; + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '\OpenAPI\Client\Model\\' . $data->{$discriminator}; + if (is_subclass_of($subclass, $class)) { + $class = $subclass; + } + } + + /** @var ModelInterface $instance */ + $instance = new $class(); + foreach ($instance::openAPITypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter)) { + continue; + } + + if (!isset($data->{$instance::attributeMap()[$property]})) { + if ($instance::isNullable($property)) { + $instance->$propertySetter(null); + } + + continue; + } + + if (isset($data->{$instance::attributeMap()[$property]})) { + $propertyValue = $data->{$instance::attributeMap()[$property]}; + $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } + } + + /** + * Build a query string from an array of key value pairs. + * + * This function can use the return value of `parse()` to build a query + * string. This function does not modify the provided keys when an array is + * encountered (like `http_build_query()` would). + * + * The function is copied from https://github.com/guzzle/psr7/blob/a243f80a1ca7fe8ceed4deee17f12c1930efe662/src/Query.php#L59-L112 + * with a modification which is described in https://github.com/guzzle/psr7/pull/603 + * + * @param array $params Query string parameters. + * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 + * to encode using RFC3986, or PHP_QUERY_RFC1738 + * to encode using RFC1738. + */ + public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): string + { + if (!$params) { + return ''; + } + + if ($encoding === false) { + $encoder = function (string $str): string { + return $str; + }; + } elseif ($encoding === PHP_QUERY_RFC3986) { + $encoder = 'rawurlencode'; + } elseif ($encoding === PHP_QUERY_RFC1738) { + $encoder = 'urlencode'; + } else { + throw new \InvalidArgumentException('Invalid type'); + } + + $castBool = Configuration::BOOLEAN_FORMAT_INT == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString() + ? function ($v) { return (int) $v; } + : function ($v) { return $v ? 'true' : 'false'; }; + + $qs = ''; + foreach ($params as $k => $v) { + $k = $encoder((string) $k); + if (!is_array($v)) { + $qs .= $k; + $v = is_bool($v) ? $castBool($v) : $v; + if ($v !== null) { + $qs .= '='.$encoder((string) $v); + } + $qs .= '&'; + } else { + foreach ($v as $vv) { + $qs .= $k; + $vv = is_bool($vv) ? $castBool($vv) : $vv; + if ($vv !== null) { + $qs .= '='.$encoder((string) $vv); + } + $qs .= '&'; + } + } + } + + return $qs ? (string) substr($qs, 0, -1) : ''; + } +} diff --git a/sql b/sql deleted file mode 100644 index e69de29b..00000000 -- 2.39.5